tryAGI.Anthropic 3.8.4-dev.15

Prefix Reserved
This is a prerelease version of tryAGI.Anthropic.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package tryAGI.Anthropic --version 3.8.4-dev.15
                    
NuGet\Install-Package tryAGI.Anthropic -Version 3.8.4-dev.15
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="tryAGI.Anthropic" Version="3.8.4-dev.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="tryAGI.Anthropic" Version="3.8.4-dev.15" />
                    
Directory.Packages.props
<PackageReference Include="tryAGI.Anthropic" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add tryAGI.Anthropic --version 3.8.4-dev.15
                    
#r "nuget: tryAGI.Anthropic, 3.8.4-dev.15"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package tryAGI.Anthropic@3.8.4-dev.15
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=tryAGI.Anthropic&version=3.8.4-dev.15&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=tryAGI.Anthropic&version=3.8.4-dev.15&prerelease
                    
Install as a Cake Tool

Anthropic

Nuget package dotnet License: MIT Discord

Disclaimer: This package is not affiliated with, endorsed by, or sponsored by Anthropic. Anthropic and Claude are trademarks of Anthropic, PBC.

Features 🔥

  • Fully generated C# SDK based on official OpenAPI specification using AutoSDK
  • Automatic releases of new preview versions if there was an update to the OpenAPI specification
  • Source generator to define tools natively through C# interfaces
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0
  • Supporting Microsoft.Extensions.AI
  • Supports all endpoints of the API, including batch requests, count tokens, and prompt caching.

Usage

using Anthropic;

using var client = new AnthropicClient(apiKey);

var messageParams = new CreateMessageParams()
{   
    Model = new Model(ModelVariant6.Claude35SonnetLatest),
    Messages = [
        new InputMessage(InputMessageRole.User, "What's the weather like today?"),
        new InputMessage(InputMessageRole.Assistant, "Sure! Could you please provide me with your location?"),
        new InputMessage(InputMessageRole.User, "Dubai, UAE")
    ],
    MaxTokens = 250
};
var response = await client.Messages.MessagesPostAsync(messageParams);

Tools

using CSharpToJsonSchema;

public enum Unit
{
    Celsius,
    Fahrenheit,
}

public class Weather
{
    public string Location { get; set; } = string.Empty;
    public double Temperature { get; set; }
    public Unit Unit { get; set; }
    public string Description { get; set; } = string.Empty;
}

[GenerateJsonSchema]
public interface IWeatherFunctions
{
    [Description("Get the current weather in a given location")]
    public Weather GetCurrentWeather(
        [Description("The city and state, e.g. San Francisco, CA")] string location,
        Unit unit = Unit.Celsius);
    
    [Description("Get the current weather in a given location")]
    public Task<Weather> GetCurrentWeatherAsync(
        [Description("The city and state, e.g. San Francisco, CA")] string location,
        Unit unit = Unit.Celsius,
        CancellationToken cancellationToken = default);
}

public class WeatherService : IWeatherFunctions
{
    public Weather GetCurrentWeather(string location, Unit unit = Unit.Celsius)
    {
        return new Weather
        {
            Location = location,
            Temperature = 22.0,
            Unit = unit,
            Description = "Sunny",
        };
    }
    
    public Task<Weather> GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default)
    {
        return Task.FromResult(new Weather
        {
            Location = location,
            Temperature = 22.0,
            Unit = unit,
            Description = "Sunny",
        });
    }
}
using Anthropic;

using var client = new AnthropicClient(apiKey);

var service = new WeatherService();
var tools = service.AsTools();

var messageParams = new CreateMessageParams()
{   
    Model = new Model(ModelVariant6.Claude35SonnetLatest),
    Messages = [new InputMessage(InputMessageRole.User, "What is the current temperature in Dubai, UAE in Celsius?")],
    MaxTokens = 4096,
    System = "You are a helpful weather assistant.",
    ToolChoice = new ToolChoice(new ToolChoiceAuto()),
    Tools = tools
};
var response = await client.Messages.MessagesPostAsync(messageParams);

messageParams.Messages.Add(response.AsInputMessage());

foreach (var toolUse in response.Content.Value2!
     .Where(x => x.IsToolUse)
     .Select(x => x.ToolUse))
{
    var json = await service.CallAsync(
        functionName: toolUse!.Name,
        argumentsAsJson: toolUse.Input.AsJson());
    messageParams.Messages.Add(json.AsToolCall(toolUse));
}

response = await client.Messages.MessagesPostAsync(messageParams);

Microsoft.Extensions.AI

The SDK implements IChatClient for seamless integration with the .NET AI ecosystem:

using Anthropic;
using Microsoft.Extensions.AI;

IChatClient chatClient = new AnthropicClient(apiKey);

var response = await chatClient.GetResponseAsync(
    [new ChatMessage(ChatRole.User, "Hello!")],
    new ChatOptions { ModelId = "claude-sonnet-4-20250514" });

Console.WriteLine(response.Text);

Chat Client Five Random Lines

using var client = GetAuthenticatedChatClient();

var response = await client.GetResponseAsync(
    messages: [new ChatMessage(ChatRole.User, "Generate 5 random words.")],
    new ChatOptions
    {
        ModelId = DefaultModel,
        ResponseFormat = ChatResponseFormatForType<StringArraySchema>(),
        Tools = new List<AITool>(),
    });

Console.WriteLine(response.ToString());

Chat Client Five Random Words Streaming

using var client = GetAuthenticatedChatClient();

var enumerable = client.GetStreamingResponseAsync(
    messages: [new ChatMessage(ChatRole.User, "Generate 5 random words.")],
    new ChatOptions
    {
        ModelId = DefaultModel,
    });

var deltas = new List<string>();
await foreach (var response in enumerable)
{
    Console.Write(response.ToString());

    deltas.Add(response.ToString());
}

Chat Client Five Random Words

using var client = GetAuthenticatedChatClient();

var response = await client.GetResponseAsync(
    messages: [new ChatMessage(ChatRole.User, "Generate 5 random words.")],
    new ChatOptions
    {
        ModelId = DefaultModel,
    });

Console.WriteLine(response.ToString());

Complete History

using var client = new AnthropicClient(apiKey);

var response = await client.MessagesPostAsync(
    model: DefaultModel,
    messages: [
        "What's the weather like today?",
        "Sure! Could you please provide me with your location?".AsAssistantMessage(),
        "Dubai, UAE",
    ],
    maxTokens: 300,
    temperature: 0);

Console.WriteLine(response.AsSimpleText());

Five Random Words

using var client = new AnthropicClient(apiKey);

var response = await client.MessagesPostAsync(
    model: DefaultModel,
    messages: ["Generate 5 random words."],
    maxTokens: 300,
    temperature: 0);

Console.WriteLine(response.AsSimpleText());

Streaming

using var client = new AnthropicClient(apiKey);

var enumerable = client.CreateMessageAsStreamAsync(new CreateMessageParams
{
    Model = DefaultModel,
    Messages = ["Once upon a time"],
    MaxTokens = 250,
});

var deltas = new List<string>();
await foreach (var response in enumerable)
{
    Console.Write(response.ContentBlockDelta?.Delta.TextDelta?.Text);

    deltas.Add(response.ContentBlockDelta?.Delta.TextDelta?.Text ?? string.Empty);
}

Ecosystem maintenance

This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.

Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.

Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.

Support

Priority place for bugs: https://github.com/tryAGI/Anthropic/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Anthropic/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on tryAGI.Anthropic:

Package Downloads
LangChain

LangChain meta-package with the most used things.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on tryAGI.Anthropic:

Repository Stars
tryAGI/LangChain
C# implementation of LangChain. We try to be as close to the original as possible in terms of abstractions, but are open to new entities.
Version Downloads Last Updated
3.8.4-dev.17 37 9/8/2026
3.8.4-dev.16 37 9/8/2026
3.8.4-dev.15 50 9/4/2026
3.8.4-dev.14 47 9/4/2026
3.8.4-dev.13 102 9/2/2026
3.8.4-dev.12 54 9/1/2026
3.8.4-dev.10 59 8/29/2026
3.8.3 1,965 6/17/2026
3.8.3-dev.10 88 6/17/2026
3.8.3-dev.9 77 6/16/2026
3.8.3-dev.8 99 6/16/2026
3.8.3-dev.7 103 6/16/2026
3.8.3-dev.5 102 5/27/2026
3.8.3-dev.4 80 5/26/2026
3.8.3-dev.3 82 5/21/2026
3.8.2 182 4/30/2026
3.8.2-dev.1 73 4/30/2026
3.8.1-dev.94 92 4/1/2026
3.8.1-dev.89 92 3/29/2026
3.8.1-dev.88 92 3/29/2026
Loading failed