LiteLLM 1.104.0

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

<div align="center"> <img src="assets/nuget-icon.png" alt="LiteLLM .NET SDK" width="112" /> <h1>LiteLLM .NET SDK</h1> <p><strong>One gateway. 100+ AI providers. A native, strongly typed .NET experience.</strong></p> <p>Build provider-independent AI products on LiteLLM with generated C# models, async APIs, source-generated JSON serialization, and an SDK that tracks the upstream OpenAPI surface.</p>

NuGet GitHub Packages CI License: MIT .NET 10 </div>


Why LiteLLM for .NET?

LiteLLM turns OpenAI, Anthropic, Azure OpenAI, Amazon Bedrock, Google Gemini, Vertex AI, Cohere, and many more providers into one OpenAI-compatible AI Gateway. This SDK brings that gateway to .NET without hand-written HTTP plumbing.

  • Broad API coverage — chat, responses, embeddings, images, audio, batches, files, assistants, reranking, guardrails, budgets, keys, teams, models, health, and gateway administration.
  • Strongly typed by default — generated request models, response models, enums, unions, endpoint clients, and cancellation support.
  • Built for modern .NET — nullable reference types, analyzers, source-generated System.Text.Json, trimming analysis, NativeAOT awareness, assembly signing, and reproducible builds.
  • Provider freedom — change the model or routing policy at the gateway while keeping application code stable.
  • Spec-driven updates — regenerate from LiteLLM's published Swagger definition with one script; scheduled automation detects upstream API changes.
  • Release-ready packages — MinVer derives package versions from Git tags, Source Link connects packages to source, and symbol packages improve debugging.

This community SDK is maintained by loud-technology and generated from the LiteLLM OpenAPI specification. It is not an official BerriAI/LiteLLM SDK.

Requirements

LiteLLM listens on http://localhost:4000 by default.

Install

NuGet.org

Install directly from the public NuGet.org registry:

dotnet add package LiteLLM

GitHub Packages

The same package is also published to the loud-technology GitHub Packages registry. GitHub requires authentication to download NuGet packages.

Create a personal access token (classic) with the read:packages scope, then register the source once:

export GITHUB_PACKAGES_USER="your-github-username"
export GITHUB_PACKAGES_TOKEN="ghp_your-read-packages-token"

dotnet nuget add source \
  --username "$GITHUB_PACKAGES_USER" \
  --password "$GITHUB_PACKAGES_TOKEN" \
  --store-password-in-clear-text \
  --name loud-technology \
  "https://nuget.pkg.github.com/loud-technology/index.json"

dotnet add package LiteLLM \
  --source "https://nuget.pkg.github.com/loud-technology/index.json"

Use a token limited to read:packages, never commit it, and authorize it for the organization if loud-technology enforces SAML SSO. On macOS and Linux, keep the user-level NuGet configuration private because authenticated sources require --store-password-in-clear-text.

Quick start

Configure the gateway once:

export LITELLM_API_KEY="sk-your-litellm-key"
export LITELLM_BASE_URL="http://localhost:4000"

Then send a provider-independent chat completion:

using LiteLLM;

using var client = LiteLLMClient.CreateFromEnvironment();

var responseJson = await client.ChatCompletions.ChatCompletionV1ChatCompletionsPostAsync(
    new ChatCompletionV1ChatCompletionsPostRequest
    {
        Model = "gpt-4o-mini",
        Messages =
        [
            new ChatCompletionUserMessage
            {
                Content = "Explain why a unified AI gateway matters in one sentence.",
            },
        ],
    });

Console.WriteLine(responseJson);

The model name is resolved by your LiteLLM configuration, so it may represent a concrete provider model, an alias, or a load-balanced deployment group.

Configure the client

Explicit credentials and gateway URL

using var client = new LiteLLMClient(
    apiKey: "sk-your-litellm-key",
    baseUri: new Uri("https://ai-gateway.example.com"));

Reuse HttpClient

Use an application-managed HttpClient for custom handlers, proxies, telemetry, or dependency-injection lifetimes:

using var httpClient = new HttpClient
{
    Timeout = TimeSpan.FromSeconds(90),
};

using var client = new LiteLLMClient(
    apiKey: Environment.GetEnvironmentVariable("LITELLM_API_KEY")!,
    httpClient: httpClient,
    baseUri: new Uri("https://ai-gateway.example.com"),
    disposeHttpClient: false);

Environment variables

Variable Purpose Default
LITELLM_API_KEY Bearer credential used by CreateFromEnvironment() Required by the factory
LITELLM_BASE_URL Base URL of your LiteLLM proxy http://localhost:4000
LITELLM_MODEL Model used by the optional live integration test gpt-4o-mini

Never commit keys. Use environment variables, .NET user secrets, or your cloud secret manager.

API surface

The root client groups operations by domain, making the full LiteLLM gateway discoverable from IntelliSense:

client.ChatCompletions; // OpenAI-compatible chat completions
client.Responses;       // Responses API
client.Embeddings;      // Vector embeddings
client.Images;          // Image generation and editing
client.Audio;           // Speech and transcription
client.ModelManagement;// Available models and model metadata
client.Health;          // Gateway health and readiness
client.Guardrails;      // Guardrail configuration and usage
client.KeyManagement;   // Virtual keys and access control
client.TeamManagement;  // Teams, members, and permissions
client.BudgetManagement;// Budgets and spend controls

Because LiteLLM's Swagger surface evolves quickly, rely on IDE completion and the generated XML documentation for the exact methods and models in your installed package version.

Errors, cancellation, and raw responses

Every async operation accepts a CancellationToken. Non-success HTTP responses throw ApiException, exposing the status and response details generated by AutoSDK. Methods ending in AsResponseAsync return an AutoSDKHttpResponse<T> when your application needs status codes and headers in addition to the body.

using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30));

try
{
    var response = await client.Health.HealthLivelinessHealthLivenessGetAsResponseAsync(
        cancellationToken: cancellation.Token);

    Console.WriteLine($"LiteLLM health status: {(int)response.StatusCode}");
}
catch (ApiException exception)
{
    Console.Error.WriteLine($"LiteLLM request failed: {exception.Message}");
}

Regenerate the SDK

The project follows AutoSDK's First SDK layout. generate.sh is the single source of truth for generation.

dotnet tool install --global autosdk.cli --version 0.34.6
cd src/libs/LiteLLM
./generate.sh

The script downloads the Swagger document linked by LiteLLM's official All Endpoints (Swagger) documentation, replaces Generated/, and creates a .NET 10 client with Bearer authentication and a local proxy base URL.

Loud.Technology.LiteLLM.Sdk.slnx
├── src/
│   ├── libs/LiteLLM/
│   │   ├── Loud.Technology.LiteLLM.Sdk.csproj
│   │   ├── openapi.yaml
│   │   ├── generate.sh
│   │   └── Generated/
│   └── tests/IntegrationTests/
├── docs/
└── .github/workflows/

Build and test

Preview the documentation

Build and open the MkDocs site without blocking the terminal:

./scripts/docs-preview.sh open

Open a specific guide or generate reviewable PNG renders:

./scripts/docs-preview.sh open guides/api-surface/
./scripts/docs-preview.sh render

The preview runs at http://127.0.0.1:8123. Renders are written to artifacts/docs-preview/, which is ignored by Git. Inspect or stop the background server with:

./scripts/docs-preview.sh status
./scripts/docs-preview.sh stop

Run the full deterministic documentation audit separately with ./scripts/validate-docs.sh.

dotnet restore Loud.Technology.LiteLLM.Sdk.slnx
dotnet build Loud.Technology.LiteLLM.Sdk.slnx --configuration Release --no-restore
dotnet test Loud.Technology.LiteLLM.Sdk.slnx --configuration Release --no-build

Network-free contract tests verify the base URL, Bearer header, chat route, and serialized request body. The live example runs only when LITELLM_API_KEY is available; otherwise MSTest marks it inconclusive.

Versioning and releases

Packages use MinVer. A stable version comes directly from a semantic Git tag:

git tag v1.0.0
git push origin v1.0.0

The CI workflow restores, builds, tests, and packs in Release. Version tags publish the same .nupkg to both NuGet.org and the loud-technology GitHub Packages registry. GitHub Packages uses the workflow GITHUB_TOKEN; NuGet.org uses Trusted Publishing to exchange a GitHub OIDC token for a short-lived API key, so no permanent package credential is stored. See Release publishing for the required NuGet.org policy and NUGET_USER variable. Untagged builds are retained as artifacts and are not published.

Contributing

  1. Fork the repository and create a focused branch.
  2. If the API changed, edit generate.sh rather than generated C# files.
  3. Regenerate, then run the Release build and test commands above.
  4. Open a pull request describing the upstream spec change and behavior impact.

Generated files are intentionally committed so package builds are deterministic and consumers can inspect the exact API surface.

Security and support

License

Licensed under the MIT License. LiteLLM is a separate project and is subject to its own licensing and trademarks.

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.

Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

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.104.0 127 9/28/2026
1.96.1-dev.1 2,692 8/17/2026
1.96.0 262 8/16/2026