AIArbitration.Client 2.0.0

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

AIArbitration.Client

.NET SDK for the AIArbitration API — an intelligent AI model router that automatically selects the best model for every request based on cost, latency, capability, and compliance constraints.

Supports OpenAI, Anthropic, Google Gemini, Mistral, Groq, DeepSeek, and 100+ providers through a single endpoint.

Installation

dotnet add package AIArbitration.Client

Targets .NET 8, 9, and 10.

Quick start

// 1. Register the client (ASP.NET Core / Worker / console)
builder.Services.AddAIArbitrationClient(options =>
{
    options.BaseUrl     = "https://api.theaiarbitration.com";
    options.BearerToken = "<your-jwt-token>";
});

// 2. Inject and call
public class MyService(IAIArbitrationClient ai)
{
    public async Task<string> AskAsync(string question)
    {
        var response = await ai.ExecuteAsync(new ChatRequest
        {
            Messages = [ChatMessage.User(question)]
        });
        return response.Content;
    }
}

The engine picks the best model automatically. Set ModelId to pin a specific one (e.g. "openai/gpt-4o", "anthropic/claude-sonnet-4-5").

Configuration

Option Default Description
BaseUrl (required) Your AIArbitration API base URL
BearerToken (required) JWT obtained from POST /api/auth/login
Timeout 120 s Timeout for non-streaming requests
StreamingTimeout 10 min Timeout for streaming responses

From appsettings.json:

"AIArbitration": {
  "BaseUrl":     "https://api.theaiarbitration.com",
  "BearerToken": ""
}
builder.Services.AddAIArbitrationClient(builder.Configuration, "AIArbitration");

Streaming

await foreach (var chunk in ai.StreamAsync(new ChatRequest
{
    Messages = [ChatMessage.User("Explain async/await in C#")],
    ModelId  = "auto"   // "auto" or omit — let the engine choose
}))
{
    if (chunk.IsDone) break;
    Console.Write(chunk.Content);
}

Cost estimation (dry run)

var estimate = await ai.EstimateAsync(new ChatRequest
{
    Messages = [ChatMessage.User("Summarise this document: ...")],
});

Console.WriteLine($"Selected: {estimate.SelectedModel?.ModelId}");
Console.WriteLine($"Estimated cost: ${estimate.EstimatedCost:F6}");
Console.WriteLine($"Top candidates: {estimate.AllCandidates.Count}");

Batch execution

var requests = topics.Select(t => new ChatRequest
{
    Messages = [ChatMessage.User($"Write a title for: {t}")]
}).ToList();

var result = await ai.ExecuteBatchAsync(requests);

Console.WriteLine($"Success: {result.SuccessfulResponses.Count}/{result.SuccessfulResponses.Count + result.FailedRequests.Count}");
Console.WriteLine($"Total cost: ${result.TotalCost:F4}");

Image generation

var img = await ai.GenerateImageAsync(new ImageGenerationRequest
{
    Prompt = "A futuristic city skyline at sunset, digital art",
    Size   = "1024x1024",
    ModelId = "openai/dall-e-3"
});

Console.WriteLine(img.ImageUrl);

Model catalogue

var models = await ai.GetModelsAsync(vision: true, tier: "Flagship");
foreach (var m in models)
    Console.WriteLine($"{m.DisplayName} — ${m.CostPerMillionInputTokens}/M in tokens");

Error handling

try
{
    var response = await ai.ExecuteAsync(request);
}
catch (AIArbitrationClientException ex) when (ex.StatusCode == 429)
{
    // Rate limit — back off and retry
}
catch (AIArbitrationClientException ex) when (ex.StatusCode == 402)
{
    // Budget exceeded — notify user
}
catch (AIArbitrationClientException ex)
{
    Console.WriteLine($"Error {ex.StatusCode}: {ex.Message}");
}

Updating the bearer token

// After refreshing a JWT (e.g. on 401):
client.SetBearerToken(newJwt);

License

MIT — see LICENSE.

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 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 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

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
2.0.0 296 5/14/2026
1.0.0 97 5/4/2026

v2.0.0 — Major feature release
     - GenerateVideoAsync: text-to-video via Runway, Luma, Kling, Google Veo, HeyGen, SkyReels
     - GetVideoModelsAsync / GetVideoProvidersAsync: scored model catalogue for 3 selection modes
     - CreateWebhookAsync, ListWebhooksAsync, UpdateWebhookAsync, DeleteWebhookAsync,
       TestWebhookAsync, RotateWebhookSecretAsync, GetWebhookDeliveriesAsync: full HMAC webhook management
     - UploadFileAsync: upload images (→ DataUrl for vision) or documents (→ Content for analysis)
     - ChatMessage.ImageUrl + UserWithImage factory: attach images to vision requests
     - ChatMessage.ImageUrl passed through to LiteLLM multi-part content array