elbruno.Extensions.AI.Claude 0.1.0-preview.1

This is a prerelease version of elbruno.Extensions.AI.Claude.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package elbruno.Extensions.AI.Claude --version 0.1.0-preview.1
                    
NuGet\Install-Package elbruno.Extensions.AI.Claude -Version 0.1.0-preview.1
                    
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="elbruno.Extensions.AI.Claude" Version="0.1.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="elbruno.Extensions.AI.Claude" Version="0.1.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="elbruno.Extensions.AI.Claude" />
                    
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 elbruno.Extensions.AI.Claude --version 0.1.0-preview.1
                    
#r "nuget: elbruno.Extensions.AI.Claude, 0.1.0-preview.1"
                    
#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 elbruno.Extensions.AI.Claude@0.1.0-preview.1
                    
#: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=elbruno.Extensions.AI.Claude&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=elbruno.Extensions.AI.Claude&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Tool

elbruno.Extensions.AI.Claude

A C# library for using Claude models deployed in Microsoft Foundry, implementing the Microsoft.Extensions.AI abstractions.

Overview

This library provides an AzureClaudeClient that allows you to interact with Claude models (e.g., Claude Sonnet 4.5) deployed in Microsoft Foundry. It follows the same patterns as AzureOpenAIClient and implements the standard IChatClient interface from Microsoft.Extensions.AI.

Features

  • ✅ Full IChatClient implementation
  • ✅ Support for both streaming and non-streaming completions
  • ✅ Azure authentication using Azure Identity
  • ✅ System messages support
  • ✅ Multi-turn conversations
  • ✅ Token usage tracking
  • ✅ Configurable chat options (temperature, top-p, max tokens)

Installation

dotnet add package elbruno.Extensions.AI.Claude

Prerequisites

  1. An Azure subscription
  2. A Claude model deployed in Microsoft Foundry
  3. Appropriate Azure credentials configured

Quick Start

using Azure.Identity;
using elbruno.Extensions.AI.Claude;
using Microsoft.Extensions.AI;

// Configure the client
var endpoint = new Uri("https://your-endpoint.services.ai.azure.com");
var deploymentName = "claude-sonnet-4-5"; // Your deployment name
var credential = new DefaultAzureCredential();

// Create the client
var client = new AzureClaudeClient(endpoint, deploymentName, credential);

// Send a message
var messages = new List<ChatMessage>
{
    new(ChatRole.User, "What is the capital of France?")
};

var response = await client.CompleteAsync(messages);
Console.WriteLine(response.Message.Text);

Usage Examples

Simple Completion

var messages = new List<ChatMessage>
{
    new(ChatRole.User, "Explain quantum computing in simple terms.")
};

var response = await client.CompleteAsync(messages);
Console.WriteLine(response.Message.Text);
Console.WriteLine($"Tokens used: {response.Usage?.TotalTokenCount}");

Streaming Completion

var messages = new List<ChatMessage>
{
    new(ChatRole.User, "Write a short story about a robot.")
};

await foreach (var update in client.CompleteStreamingAsync(messages))
{
    if (!string.IsNullOrEmpty(update.Text))
    {
        Console.Write(update.Text);
    }
}

Multi-turn Conversation

var conversation = new List<ChatMessage>
{
    new(ChatRole.System, "You are a helpful coding assistant."),
    new(ChatRole.User, "How do I create a list in Python?"),
};

var response1 = await client.CompleteAsync(conversation);
conversation.Add(response1.Message);

conversation.Add(new ChatMessage(ChatRole.User, "Can you show me an example?"));
var response2 = await client.CompleteAsync(conversation);

With Chat Options

var options = new ChatOptions
{
    Temperature = 0.7,
    TopP = 0.9,
    MaxOutputTokens = 2048
};

var messages = new List<ChatMessage>
{
    new(ChatRole.User, "Generate creative ideas for a tech startup.")
};

var response = await client.CompleteAsync(messages, options);

Configuration

Environment Variables

You can configure the client using environment variables:

export AZURE_CLAUDE_ENDPOINT="https://your-endpoint.services.ai.azure.com"
export AZURE_CLAUDE_MODEL="claude-sonnet-4-5"

Authentication

The library uses Azure Identity for authentication. You can use any of the following:

  • DefaultAzureCredential (recommended for development and production)
  • ManagedIdentityCredential (for Azure resources)
  • EnvironmentCredential (for environment variables)
  • AzureCliCredential (for local development)

Example with specific credential:

var credential = new ManagedIdentityCredential();
var client = new AzureClaudeClient(endpoint, deploymentName, credential);

Supported Models

This library supports Claude models deployed in Microsoft Foundry through global standard deployment. The following models are currently available:

Available Models

  • Claude Sonnet 4.5 (deployment name: claude-sonnet-4-5) - Anthropic's most capable model for building real-world agents and handling complex, long-horizon tasks. Best for agentic workflows, computer use capabilities, and production deployments.

  • Claude Haiku 4.5 (deployment name: claude-haiku-4-5) - Delivers near-frontier performance with optimal speed and cost. One of the best coding and agent models, ideal for free products and scaled sub-agents.

  • Claude Opus 4.1 (deployment name: claude-opus-4-1) - Industry leader for coding. Delivers sustained performance on long-running tasks requiring focused effort and thousands of steps, significantly expanding what AI agents can solve.

All models support:

  • 1 million token context window
  • Extended thinking for enhanced reasoning
  • Image and text input
  • Code generation, analysis, and debugging (Sonnet 4.5 and Opus 4.1)

Choosing the Right Model

  • Claude Sonnet 4.5: Best for balanced performance and capabilities, production workflows, complex reasoning, and agentic tasks
  • Claude Haiku 4.5: Best for speed and cost optimization, high-volume processing, fast responses
  • Claude Opus 4.1: Best for complex coding tasks, long-running agent workflows, and enterprise applications requiring sustained performance

API Reference

AzureClaudeClient

Constructor
public AzureClaudeClient(
    Uri endpoint,
    string modelId,
    TokenCredential credential,
    HttpClient? httpClient = null)
Properties
  • Metadata - Returns ChatClientMetadata with provider name and model ID
Methods
  • CompleteAsync - Sends a completion request and returns the full response
  • CompleteStreamingAsync - Sends a streaming completion request
  • GetService - Gets a service of the specified type
  • Dispose - Disposes resources

Building the Project

# Clone the repository
git clone https://github.com/elbruno/elbruno-extensions-ai-claude.git
cd elbruno-extensions-ai-claude

# Build the solution
dotnet build

# Run tests
dotnet test

# Pack the NuGet package
dotnet pack src/elbruno.Extensions.AI.Claude/elbruno.Extensions.AI.Claude.csproj

Testing

The project includes unit tests for core functionality. Run them with:

dotnet test

Sample Application

A sample console application is included in the samples directory. To run it:

# Set environment variables
export AZURE_CLAUDE_ENDPOINT="your-endpoint"
export AZURE_CLAUDE_MODEL="claude-sonnet-4-5"

# Run the sample
dotnet run --project samples/elbruno.Extensions.AI.Claude.Samples

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

References

Support

For issues and questions:

  • Open an issue on GitHub
  • Contact: El Bruno

Changelog

0.1.0 (Initial Release)

  • Initial implementation of AzureClaudeClient
  • Support for completions and streaming
  • Azure authentication support
  • Full IChatClient interface implementation
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 elbruno.Extensions.AI.Claude:

Package Downloads
AIKit.Clients.AzureClaude

Azure Claude client provider for AIKit, supporting chat with managed identity.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on elbruno.Extensions.AI.Claude:

Repository Stars
microsoft/Generative-AI-for-beginners-dotnet
Five lessons, learn how to really apply AI to your .NET Applications
Version Downloads Last Updated
0.1.0-preview.6 1,311 11/26/2025
0.1.0-preview.5 209 11/26/2025
0.1.0-preview.4 363 11/21/2025
0.1.0-preview.3 302 11/21/2025
0.1.0-preview.2 342 11/21/2025
0.1.0-preview.1 326 11/21/2025