ClaudeIntegratorLibraryJCdiaz 1.0.5

dotnet add package ClaudeIntegratorLibraryJCdiaz --version 1.0.5
                    
NuGet\Install-Package ClaudeIntegratorLibraryJCdiaz -Version 1.0.5
                    
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="ClaudeIntegratorLibraryJCdiaz" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ClaudeIntegratorLibraryJCdiaz" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="ClaudeIntegratorLibraryJCdiaz" />
                    
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 ClaudeIntegratorLibraryJCdiaz --version 1.0.5
                    
#r "nuget: ClaudeIntegratorLibraryJCdiaz, 1.0.5"
                    
#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 ClaudeIntegratorLibraryJCdiaz@1.0.5
                    
#: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=ClaudeIntegratorLibraryJCdiaz&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=ClaudeIntegratorLibraryJCdiaz&version=1.0.5
                    
Install as a Cake Tool

🧠 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 205 10/9/2025
1.0.3 191 10/7/2025
1.0.2 198 10/6/2025
1.0.1 192 10/2/2025
1.0.0 193 10/1/2025