AIArbitration.Client
2.0.0
dotnet add package AIArbitration.Client --version 2.0.0
NuGet\Install-Package AIArbitration.Client -Version 2.0.0
<PackageReference Include="AIArbitration.Client" Version="2.0.0" />
<PackageVersion Include="AIArbitration.Client" Version="2.0.0" />
<PackageReference Include="AIArbitration.Client" />
paket add AIArbitration.Client --version 2.0.0
#r "nuget: AIArbitration.Client, 2.0.0"
#:package AIArbitration.Client@2.0.0
#addin nuget:?package=AIArbitration.Client&version=2.0.0
#tool nuget:?package=AIArbitration.Client&version=2.0.0
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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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