DeepInfra 1.0.2-dev.10

This is a prerelease version of DeepInfra.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package DeepInfra --version 1.0.2-dev.10
                    
NuGet\Install-Package DeepInfra -Version 1.0.2-dev.10
                    
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="DeepInfra" Version="1.0.2-dev.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeepInfra" Version="1.0.2-dev.10" />
                    
Directory.Packages.props
<PackageReference Include="DeepInfra" />
                    
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 DeepInfra --version 1.0.2-dev.10
                    
#r "nuget: DeepInfra, 1.0.2-dev.10"
                    
#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 DeepInfra@1.0.2-dev.10
                    
#: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=DeepInfra&version=1.0.2-dev.10&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DeepInfra&version=1.0.2-dev.10&prerelease
                    
Install as a Cake Tool

DeepInfra

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official DeepInfra OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0
  • Support all DeepInfra API endpoints including Object Detection, Token Classification, Image Classification, Fill Mask and more.
  • Microsoft.Extensions.AI IChatClient and IEmbeddingGenerator support via tryAGI.OpenAI CustomProviders

Usage

To interact with the OpenAI like API, you need to use tryAGI.OpenAI library:

<PackageReference Include="tryAGI.OpenAI" Version="3.7.0" />
using OpenAI;

using var client = CustomProviders.DeepInfra(apiKey);
var enumerable = api.Chat.CreateChatCompletionAsStreamAsync(
    model: "meta-llama/Meta-Llama-3-8B-Instruct",
    messages: ["What is the capital of the United States?"]);

await foreach (var response in enumerable)
{
    Console.Write(response.Choices[0].Delta.Content);
}

Microsoft.Extensions.AI (MEAI) Support

DeepInfra provides an OpenAI-compatible API. For IChatClient and IEmbeddingGenerator support via Microsoft.Extensions.AI, use the tryAGI.OpenAI package:

dotnet add package tryAGI.OpenAI
using OpenAI;
using Microsoft.Extensions.AI;

using var client = CustomProviders.DeepInfra(apiKey);

// IChatClient
IChatClient chatClient = client;
var response = await chatClient.GetResponseAsync(
    "Hello!",
    new ChatOptions { ModelId = "Qwen/Qwen2.5-72B-Instruct" });

// IEmbeddingGenerator
IEmbeddingGenerator<string, Embedding<float>> generator = client;
var embeddings = await generator.GenerateAsync(
    ["Hello, world!"],
    new EmbeddingGenerationOptions { ModelId = "BAAI/bge-en-icl" });

CLI

dotnet tool install --global DeepInfra.CLI --prerelease
deep-infra api --help

Chat Client Get Response Async

using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

var response = await chatClient.GetResponseAsync(
    [new Meai.ChatMessage(Meai.ChatRole.User, "Say hello in exactly 3 words.")],
    new Meai.ChatOptions { ModelId = DeepInfraModel });

var text = response.Messages[0].Text;
Console.WriteLine(text);

Chat Client Get Streaming Response Async

using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

var updates = new List<Meai.ChatResponseUpdate>();
await foreach (var update in chatClient.GetStreamingResponseAsync(
    [new Meai.ChatMessage(Meai.ChatRole.User, "Count from 1 to 5.")],
    new Meai.ChatOptions { ModelId = DeepInfraModel }))
{
    updates.Add(update);
    var text = string.Concat(update.Contents.OfType<Meai.TextContent>().Select(c => c.Text));
    if (!string.IsNullOrEmpty(text))
    {
        Console.Write(text);
    }
}
Console.WriteLine();

Chat Client Returns Usage

using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

var response = await chatClient.GetResponseAsync(
    [new Meai.ChatMessage(Meai.ChatRole.User, "Say 'hi'.")],
    new Meai.ChatOptions { ModelId = DeepInfraModel });

Console.WriteLine($"Input: {response.Usage.InputTokenCount}, Output: {response.Usage.OutputTokenCount}, Total: {response.Usage.TotalTokenCount}");

Chat Client Tool Calling Multi Turn

using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

var tool = Meai.AIFunctionFactory.Create(
    (string city) => city switch
    {
        "Paris" => "22°C, sunny",
        "London" => "15°C, cloudy",
        _ => "Unknown",
    },
    name: "GetWeather",
    description: "Gets the current weather for a city");

var chatOptions = new Meai.ChatOptions
{
    ModelId = DeepInfraModel,
    Tools = [tool],
};

var messages = new List<Meai.ChatMessage>
{
    new(Meai.ChatRole.User, "What's the weather in Paris? Respond with the temperature only."),
};

// First turn — get tool call
var response = await chatClient.GetResponseAsync(
    (IEnumerable<Meai.ChatMessage>)messages, chatOptions);

var functionCall = response.Messages
    .SelectMany(m => m.Contents)
    .OfType<Meai.FunctionCallContent>()
    .First();

// Execute tool and add result
var toolResult = await tool.InvokeAsync(
    functionCall.Arguments is { } args
        ? new Meai.AIFunctionArguments(args)
        : null);
messages.AddRange(response.Messages);
messages.Add(new Meai.ChatMessage(Meai.ChatRole.Tool,
    new Meai.AIContent[]
    {
        new Meai.FunctionResultContent(functionCall.CallId, toolResult),
    }));

// Second turn — get final response
var finalResponse = await chatClient.GetResponseAsync(
    (IEnumerable<Meai.ChatMessage>)messages, chatOptions);

var text = finalResponse.Messages[0].Text;
Console.WriteLine($"Final response: {text}");

Chat Client Tool Calling Single Turn

using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

var tool = Meai.AIFunctionFactory.Create(
    (string city) => city switch
    {
        "Paris" => "22°C, sunny",
        "London" => "15°C, cloudy",
        _ => "Unknown",
    },
    name: "GetWeather",
    description: "Gets the current weather for a city");

var response = await chatClient.GetResponseAsync(
    [new Meai.ChatMessage(Meai.ChatRole.User, "What's the weather in Paris?")],
    new Meai.ChatOptions
    {
        ModelId = DeepInfraModel,
        Tools = [tool],
    });

var functionCall = response.Messages
    .SelectMany(m => m.Contents)
    .OfType<Meai.FunctionCallContent>()
    .FirstOrDefault();

Console.WriteLine($"Tool call: {functionCall.Name}({string.Join(", ", functionCall.Arguments?.Select(kv => $"{kv.Key}={kv.Value}") ?? [])})");

Chat Client With System Message

using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

var response = await chatClient.GetResponseAsync(
    [
        new Meai.ChatMessage(Meai.ChatRole.System, "You always respond with exactly one word."),
        new Meai.ChatMessage(Meai.ChatRole.User, "What color is the sky?"),
    ],
    new Meai.ChatOptions { ModelId = DeepInfraModel });

var text = response.Messages[0].Text;
Console.WriteLine(text);

Create Chat Completion

// Use the OpenAI SDK via CustomProviders.DeepInfra() with MEAI interface
using var client = GetAuthenticatedOpenAiClient();
Meai.IChatClient chatClient = client;

await foreach (var update in chatClient.GetStreamingResponseAsync(
    [new Meai.ChatMessage(Meai.ChatRole.User, "What is the capital of the United States?")],
    new Meai.ChatOptions { ModelId = DeepInfraModel }))
{
    var text = string.Concat(update.Contents.OfType<Meai.TextContent>().Select(c => c.Text));
    Console.Write(text);
}

Embedding Generator Batch Generate

using var client = GetAuthenticatedOpenAiClient();
Meai.IEmbeddingGenerator<string, Meai.Embedding<float>> generator = client;

var embeddings = await generator.GenerateAsync(
    ["First sentence.", "Second sentence.", "Third sentence."],
    new Meai.EmbeddingGenerationOptions { ModelId = DeepInfraEmbeddingModel });

foreach (var embedding in embeddings)
{
}
Console.WriteLine($"Generated {embeddings.Count} embeddings with {embeddings[0].Vector.Length} dimensions each");

Embedding Generator Generate Async

using var client = GetAuthenticatedOpenAiClient();
Meai.IEmbeddingGenerator<string, Meai.Embedding<float>> generator = client;

var embeddings = await generator.GenerateAsync(
    ["Hello, world!"],
    new Meai.EmbeddingGenerationOptions { ModelId = DeepInfraEmbeddingModel });

Console.WriteLine($"Embedding dimensions: {embeddings[0].Vector.Length}");

List Models

var client = new DeepInfraClient(apiKey);
var models = await client.ModelsListAsync();
foreach (var model in models)
{
    Console.WriteLine(model.ModelName);
}

Usage

var client = new DeepInfraClient(apiKey);

Me me = await client.MeAsync();
Console.WriteLine($"{me.ToJson(new JsonSerializerOptions
{
    WriteIndented = true,
})}");

Ecosystem maintenance

This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.

Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.

Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.

Support

Priority place for bugs: https://github.com/tryAGI/DeepInfra/issues Priority place for ideas and general questions: https://github.com/tryAGI/DeepInfra/discussions
Discord: https://discord.gg/Ca2xhfBf3v

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.0.2-dev.14 0 9/4/2026
1.0.2-dev.13 34 9/3/2026
1.0.2-dev.12 99 9/2/2026
1.0.2-dev.11 37 9/1/2026
1.0.2-dev.10 38 9/1/2026
1.0.2-dev.8 65 8/29/2026
1.0.2-dev.4 184 6/17/2026
1.0.2-dev.3 93 6/16/2026
1.0.2-dev.2 65 5/21/2026
1.0.1 140 4/30/2026
0.11.1-dev.157 93 4/1/2026
0.11.1-dev.153 81 3/29/2026
0.11.1-dev.147 170 3/28/2026
0.11.1-dev.145 81 3/28/2026
0.11.1-dev.143 91 3/28/2026
0.11.1-dev.142 91 3/28/2026
0.11.1-dev.139 81 3/27/2026
0.11.1-dev.130 87 3/20/2026
0.11.1-dev.127 83 3/20/2026
0.11.1-dev.126 84 3/19/2026
Loading failed