ClaudeIntegratorLibraryJCdiaz 1.0.5
dotnet add package ClaudeIntegratorLibraryJCdiaz --version 1.0.5
NuGet\Install-Package ClaudeIntegratorLibraryJCdiaz -Version 1.0.5
<PackageReference Include="ClaudeIntegratorLibraryJCdiaz" Version="1.0.5" />
<PackageVersion Include="ClaudeIntegratorLibraryJCdiaz" Version="1.0.5" />
<PackageReference Include="ClaudeIntegratorLibraryJCdiaz" />
paket add ClaudeIntegratorLibraryJCdiaz --version 1.0.5
#r "nuget: ClaudeIntegratorLibraryJCdiaz, 1.0.5"
#:package ClaudeIntegratorLibraryJCdiaz@1.0.5
#addin nuget:?package=ClaudeIntegratorLibraryJCdiaz&version=1.0.5
#tool nuget:?package=ClaudeIntegratorLibraryJCdiaz&version=1.0.5
π§ ClaudeIntegratorLibraryJCdiaz
Library for easily integrating the Claude API into .NET applications using Dependency Injection.
β¨ Features
- β
Ready-to-use dependency injection (
AddClaudeApiClient) - βοΈ Configuration from
appsettings.json - π Optional Azure Key Vault support via
Azure.Identity - πͺ Strongly typed HTTP client
- π§© Compatible with .NET 9 and previous versions (by adjusting
TargetFramework)
π Installation
Install the package from NuGet:
dotnet add package ClaudeIntegratorLibraryJCdiaz
βοΈ Configuration
{
"ClaudeApi": {
"ApiKey": "sk-ant-api03-YOUR_API_KEY_HERE",
"BaseUrl": "https://api.anthropic.com/v1",
"Model": "claude-sonnet-4-20250514",
"MaxTokens": 2048,
"Temperature": 0.7,
"ApiVersion": "2023-06-01"
}
}
π‘ Note: If using Azure Key Vault, leave
"ApiKey"empty.
π© Example β Claude API Request & Response
Request
POST https://api.anthropic.com/v1/messages
Headers
x-api-key: sk-ant-api03-xxxxx
anthropic-version: 2023-06-01
content-type: application/json
Body
{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"temperature": 1.0,
"messages": [
{
"role": "user",
"content": "Explain what LINQ is in C# in 2 sentences"
}
]
}
Response
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-20250514",
"content": [
{
"type": "text",
"text": "LINQ (Language Integrated Query) is a C# feature that allows querying data collections using SQL-like syntax directly in code. It provides methods like Where, Select, OrderBy to filter, transform and sort data declaratively."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 18,
"output_tokens": 62
}
}
π§© Usage
Basic Setup (appsettings.json)
{
"ClaudeApi": {
"ApiKey": "sk-ant-api03-YOUR_API_KEY_HERE",
"BaseUrl": "https://api.anthropic.com/v1",
"Model": "claude-sonnet-4-20250514",
"MaxTokens": 2048,
"Temperature": 0.7,
"ApiVersion": "2023-06-01"
}
}
π Use
"ApiKey": ""if youβre using Azure Key Vault. In that case, the secret must be named: ClaudeApi--ApiKey
Basic Example
using ClaudeIntegratorLibraryJCdiaz.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Register Claude API client dependency injection
builder.Services.AddClaudeApiClient(builder.Configuration);
var app = builder.Build();
app.MapGet("/", async (ClaudeApiClient claude) =>
{
var response = await claude.SendMessageAsync("Explain what LINQ is in C# in 2 sentences");
return response;
});
app.Run();
With Azure Key Vault
using Azure.Identity;
using ClaudeIntegratorLibraryJCdiaz.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using System;
var builder = WebApplication.CreateBuilder(args);
// Add Key Vault to configuration
// The secret must be named ClaudeApi--ApiKey
builder.Configuration.AddAzureKeyVault(
new Uri("https://YOUR_VAULT.vault.azure.net/"),
new DefaultAzureCredential()
);
// Configuration now includes secrets from Key Vault
builder.Services.AddClaudeApiClient(builder.Configuration);
var app = builder.Build();
app.MapGet("/", async (ClaudeIntegratorLibraryJCdiaz.Services.ClaudeApiClient claude) =>
{
var response = await claude.SendMessageAsync("Explain what LINQ is in C# in 2 sentences");
return response;
});
app.Run();
β οΈ Important Notes
π When using Azure Key Vault, the secret must be named:
ClaudeApi--ApiKey(double hyphen to represent section nesting)
ποΈ The library automatically maps Key Vault secrets using:
Section--Key β Section:Keyπ§βπ» Ensure your Azure user or app has at least the role: Key Vault Secrets User
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.9)
- Microsoft.Extensions.DependencyInjection (>= 9.0.9)
- Microsoft.Extensions.Options (>= 9.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.9)
- System.Net.Http.Json (>= 9.0.9)
- System.Text.Json (>= 9.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.