diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index b6609d9f..895f6515 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "10.1.2"
+ ".": "10.2.0"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 61c0385b..08c53799 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## 10.2.0 (2025-11-20)
+
+Full Changelog: [v10.1.2...v10.2.0](https://github.com/anthropics/anthropic-sdk-csharp/compare/v10.1.2...v10.2.0)
+
+### Features
+
+* **client:** additional methods for positional params ([8bc6323](https://github.com/anthropics/anthropic-sdk-csharp/commit/8bc6323c38ce551f995bec5e4b1584460b7f037b))
+
+
+### Bug Fixes
+
+* **client:** return correct type for foundry#WithOptions ([#18](https://github.com/anthropics/anthropic-sdk-csharp/issues/18)) ([f814a46](https://github.com/anthropics/anthropic-sdk-csharp/commit/f814a460503abf7fdf7a824b5bf446ef74d60f28))
+* use correct versions ([c78c8db](https://github.com/anthropics/anthropic-sdk-csharp/commit/c78c8db4b6effa6b1438bb879bcafdad2d155808))
+
+
+### Refactors
+
+* **client:** make unknown variants implicit ([eb0e5b6](https://github.com/anthropics/anthropic-sdk-csharp/commit/eb0e5b628d7090adc34300775043ecd26ccfffaf))
+
## 10.1.2 (2025-11-18)
Full Changelog: [v10.1.1...v10.1.2](https://github.com/anthropics/anthropic-sdk-csharp/compare/v10.1.1...v10.1.2)
diff --git a/examples/MessagesExample/Program.cs b/examples/MessagesExample/Program.cs
index 6fd7cfc8..6c8b0fc2 100644
--- a/examples/MessagesExample/Program.cs
+++ b/examples/MessagesExample/Program.cs
@@ -1,8 +1,7 @@
using System;
using Anthropic;
-using Anthropic.Models.Messages;
using Anthropic.Foundry;
-
+using Anthropic.Models.Messages;
// Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables
IAnthropicClient client = new AnthropicClient();
@@ -25,8 +24,7 @@
var message = String.Join(
"",
response
- .Content
- .Where(message => message.Value is TextBlock)
+ .Content.Where(message => message.Value is TextBlock)
.Select(message => message.Value as TextBlock)
.Select((textBlock) => textBlock.Text)
);
diff --git a/src/Anthropic.Foundry/Anthropic.Foundry.csproj b/src/Anthropic.Foundry/Anthropic.Foundry.csproj
index 7955e04b..8e87d087 100644
--- a/src/Anthropic.Foundry/Anthropic.Foundry.csproj
+++ b/src/Anthropic.Foundry/Anthropic.Foundry.csproj
@@ -1,58 +1,47 @@
-
-
- net8.0;net9.0;netstandard2.0
- enable
- enable
- Anthropic.Foundry
- Anthropic.Foundry
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- Anthropic.Foundry
- 0.0.1
- Stainless Software, Inc.
- Stainless Software, Inc.
- https://github.com/anthropics/anthropic-sdk-csharp
- https://github.com/anthropics/anthropic-sdk-csharp
- git
- PRE-RELEASE NOT FOR DISTRIBUTION
- Latest
-
-
- true
-
-
- true
-
-
- true
- snupkg
-
+ true
+
+ true
+ snupkg
+
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
-
- net8.0;net9.0;netstandard2.0
-
-
-
-
- %(RecursiveDir)/%(FileName)%(Extension)
- PreserveNewest
-
-
-
+ net8.0;net9.0;netstandard2.0
+
+
+
+ %(RecursiveDir)/%(FileName)%(Extension)
+ PreserveNewest
+
+
diff --git a/src/Anthropic.Foundry/AnthropicFoundryBearerTokenCredentials.cs b/src/Anthropic.Foundry/AnthropicFoundryBearerTokenCredentials.cs
index d735fd27..04977752 100644
--- a/src/Anthropic.Foundry/AnthropicFoundryBearerTokenCredentials.cs
+++ b/src/Anthropic.Foundry/AnthropicFoundryBearerTokenCredentials.cs
@@ -21,6 +21,7 @@ public AnthropicFoundryBearerTokenCredentials(string apiKey, string resourceName
public void Apply(HttpRequestMessage requestMessage)
{
- requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", _apiKey);
+ requestMessage.Headers.Authorization =
+ new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", _apiKey);
}
}
diff --git a/src/Anthropic.Foundry/AnthropicFoundryClient.cs b/src/Anthropic.Foundry/AnthropicFoundryClient.cs
index 792cbd5c..04c02df4 100644
--- a/src/Anthropic.Foundry/AnthropicFoundryClient.cs
+++ b/src/Anthropic.Foundry/AnthropicFoundryClient.cs
@@ -2,8 +2,8 @@
global using ValueTask = System.Threading.Tasks.Task;
#endif
-using Anthropic.Core;
using Anthropic;
+using Anthropic.Core;
namespace Anthropic.Foundry;
@@ -21,21 +21,47 @@ public class AnthropicFoundryClient : AnthropicClient
///
public AnthropicFoundryClient(IAnthropicFoundryCredentials azureCredentials)
{
- _azureCredentials = azureCredentials ?? throw new ArgumentNullException(nameof(azureCredentials));
+ _azureCredentials =
+ azureCredentials ?? throw new ArgumentNullException(nameof(azureCredentials));
var url = $"https://{azureCredentials.ResourceName}.services.ai.azure.com/anthropic";
BaseUrl = new Uri(url, UriKind.Absolute);
}
+ private AnthropicFoundryClient(
+ IAnthropicFoundryCredentials azureCredentials,
+ ClientOptions options
+ )
+ : base(options)
+ {
+ _azureCredentials =
+ azureCredentials ?? throw new ArgumentNullException(nameof(azureCredentials));
+ }
+
[Obsolete("The {nameof(APIKey)} property is not supported in this configuration.", true)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override string? APIKey
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
- get => throw new NotSupportedException($"The {nameof(APIKey)} property is not supported in this configuration.");
- init => throw new NotSupportedException($"The {nameof(APIKey)} property is not supported in this configuration.");
+ get =>
+ throw new NotSupportedException(
+ $"The {nameof(APIKey)} property is not supported in this configuration."
+ );
+ init =>
+ throw new NotSupportedException(
+ $"The {nameof(APIKey)} property is not supported in this configuration."
+ );
+ }
+
+ public override IAnthropicClient WithOptions(Func modifier)
+ {
+ return new AnthropicFoundryClient(_azureCredentials, modifier(_options));
}
- protected override ValueTask BeforeSend(HttpRequest request, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
+ protected override ValueTask BeforeSend(
+ HttpRequest request,
+ HttpRequestMessage requestMessage,
+ CancellationToken cancellationToken
+ )
{
_azureCredentials.Apply(requestMessage);
diff --git a/src/Anthropic.Foundry/AnthropicFoundryIdentityTokenCredentials.cs b/src/Anthropic.Foundry/AnthropicFoundryIdentityTokenCredentials.cs
index 1690ce88..ec17080f 100644
--- a/src/Anthropic.Foundry/AnthropicFoundryIdentityTokenCredentials.cs
+++ b/src/Anthropic.Foundry/AnthropicFoundryIdentityTokenCredentials.cs
@@ -18,7 +18,10 @@ public AnthropicFoundryIdentityTokenCredentials(AccessToken apiKey, string resou
{
if (apiKey.Equals(default) || string.IsNullOrWhiteSpace(apiKey.Token))
{
- throw new ArgumentNullException(nameof(apiKey), "Invalid/Empty api key struct is not valid");
+ throw new ArgumentNullException(
+ nameof(apiKey),
+ "Invalid/Empty api key struct is not valid"
+ );
}
_apiKey = apiKey;
ResourceName = resourceName ?? throw new ArgumentNullException(nameof(resourceName));
@@ -29,6 +32,7 @@ public AnthropicFoundryIdentityTokenCredentials(AccessToken apiKey, string resou
public void Apply(HttpRequestMessage requestMessage)
{
//TODO implement token refresh
- requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", _apiKey.Token);
+ requestMessage.Headers.Authorization =
+ new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", _apiKey.Token);
}
}
diff --git a/src/Anthropic.Foundry/IAnthropicFoundryCredentials.cs b/src/Anthropic.Foundry/IAnthropicFoundryCredentials.cs
index befcd680..763eb7e4 100644
--- a/src/Anthropic.Foundry/IAnthropicFoundryCredentials.cs
+++ b/src/Anthropic.Foundry/IAnthropicFoundryCredentials.cs
@@ -27,34 +27,47 @@ public class DefaultAnthropicFoundryCredentials
/// ANTHROPIC_FOUNDRY_API_KEY=your_api_key
///
/// or use Azure Identity to provide a token.
- ///
+ ///
/// If both are set, the API key environment variable will take precedence.
- ///
+ ///
///
/// The resource name or if null loaded from the environment variable ANTHROPIC_FOUNDRY_RESOURCE
///
- public static async ValueTask FromEnv(string? resourceName = null)
+ public static async ValueTask FromEnv(
+ string? resourceName = null
+ )
{
- if(Environment.GetEnvironmentVariable("ANTHROPIC_FOUNDRY_RESOURCE") is not string envResourceName
- || (string.IsNullOrWhiteSpace(resourceName) && string.IsNullOrWhiteSpace(envResourceName)))
+ if (
+ Environment.GetEnvironmentVariable("ANTHROPIC_FOUNDRY_RESOURCE")
+ is not string envResourceName
+ || (
+ string.IsNullOrWhiteSpace(resourceName)
+ && string.IsNullOrWhiteSpace(envResourceName)
+ )
+ )
{
return null;
}
- if (Environment.GetEnvironmentVariable("ANTHROPIC_FOUNDRY_API_KEY") is string apiKey && !string.IsNullOrWhiteSpace(apiKey))
+ if (
+ Environment.GetEnvironmentVariable("ANTHROPIC_FOUNDRY_API_KEY") is string apiKey
+ && !string.IsNullOrWhiteSpace(apiKey)
+ )
{
return new AnthropicFoundryApiKeyCredentials(apiKey, resourceName ?? envResourceName);
}
var defaultCredentialsProvider = new DefaultAzureCredential();
- var azureToken = await defaultCredentialsProvider.GetTokenAsync(new()
- {
-
- }).ConfigureAwait(false);
+ var azureToken = await defaultCredentialsProvider
+ .GetTokenAsync(new() { })
+ .ConfigureAwait(false);
if (!azureToken.Equals(default))
{
- return new AnthropicFoundryIdentityTokenCredentials(azureToken, resourceName ?? envResourceName);
+ return new AnthropicFoundryIdentityTokenCredentials(
+ azureToken,
+ resourceName ?? envResourceName
+ );
}
return null;
diff --git a/src/Anthropic.Tests/AnthropicTestClients.cs b/src/Anthropic.Tests/AnthropicTestClients.cs
index 9bef486b..7172c476 100644
--- a/src/Anthropic.Tests/AnthropicTestClients.cs
+++ b/src/Anthropic.Tests/AnthropicTestClients.cs
@@ -18,29 +18,35 @@ public AnthropicTestClientsAttribute(TestSupportTypes testSupportTypes = TestSup
public override IEnumerable