AI21 0.0.0-dev.281
See the version list below for details.
dotnet add package AI21 --version 0.0.0-dev.281
NuGet\Install-Package AI21 -Version 0.0.0-dev.281
<PackageReference Include="AI21" Version="0.0.0-dev.281" />
<PackageVersion Include="AI21" Version="0.0.0-dev.281" />
<PackageReference Include="AI21" />
paket add AI21 --version 0.0.0-dev.281
#r "nuget: AI21, 0.0.0-dev.281"
#:package AI21@0.0.0-dev.281
#addin nuget:?package=AI21&version=0.0.0-dev.281&prerelease
#tool nuget:?package=AI21&version=0.0.0-dev.281&prerelease
AI21
Features 🔥
- Fully generated C# SDK based on official OpenAPI specification using OpenApiGenerator
- 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
- Microsoft.Extensions.AI
IChatClientsupport
Usage
using AI21;
usung var api = new Ai21Client(apiKey);
await api.Chat.V1J2UltraChatAsync(
messages:
[
new ChatMessage
{
Text = "Hello",
Role = RoleType.User,
}
],
system: string.Empty,
cancellationToken: CancellationToken.None);
CLI
dotnet tool install --global AI21.CLI --prerelease
ai21 api --help
Microsoft.Extensions.AI
The SDK implements IChatClient:
using AI21;
using Microsoft.Extensions.AI;
IChatClient chatClient = new Ai21Client(apiKey);
var response = await chatClient.GetResponseAsync(
[new ChatMessage(ChatRole.User, "Hello!")],
new ChatOptions { ModelId = "jamba-1.5-mini" });
Console.WriteLine(response.Text);
Chat Client Five Random Words Streaming
using var client = GetAuthorizedClient();
IChatClient chatClient = client;
var updates = chatClient.GetStreamingResponseAsync(
[
new ChatMessage(ChatRole.User, "Generate 5 random words.")
],
new ChatOptions
{
ModelId = "jamba-large",
});
var deltas = new List<string>();
await foreach (var update in updates)
{
if (!string.IsNullOrWhiteSpace(update.Text))
{
deltas.Add(update.Text);
}
}
Chat Client Five Random Words
using var client = GetAuthorizedClient();
IChatClient chatClient = client;
var response = await chatClient.GetResponseAsync(
[
new ChatMessage(ChatRole.User, "Generate 5 random words.")
],
new ChatOptions
{
ModelId = "jamba-large",
});
Chat Client Get Service Returns Chat Client Metadata
using var client = CreateTestClient();
IChatClient chatClient = client;
var metadata = chatClient.GetService<ChatClientMetadata>();
Chat Client Get Service Returns Null For Unknown Key
using var client = CreateTestClient();
IChatClient chatClient = client;
var result = chatClient.GetService<ChatClientMetadata>(serviceKey: "unknown");
Chat Client Get Service Returns Self
using var client = CreateTestClient();
IChatClient chatClient = client;
var self = chatClient.GetService<Ai21Client>();
Chat Client Tool Calling Multi Turn
using var client = GetAuthorizedClient();
IChatClient chatClient = client;
var getWeatherTool = AIFunctionFactory.Create(
(string location) => $"The weather in {location} is sunny, 72°F",
"GetWeather",
"Gets the current weather for a location");
var messages = new List<ChatMessage>
{
new(ChatRole.User, "What's the weather in Seattle?"),
};
var options = new ChatOptions
{
ModelId = "jamba-large",
Tools = [getWeatherTool],
};
// First turn: model should call the tool
var response = await chatClient.GetResponseAsync(messages, options);
var functionCall = response.Messages
.SelectMany(m => m.Contents)
.OfType<FunctionCallContent>()
.FirstOrDefault();
// Add assistant response with tool call and tool result
messages.AddRange(response.Messages);
var toolResult = await getWeatherTool.InvokeAsync(
functionCall!.Arguments is { } args ? new AIFunctionArguments(args) : null);
messages.Add(new ChatMessage(ChatRole.Tool,
[
new FunctionResultContent(functionCall.CallId, toolResult),
]));
// Second turn: model should respond with the weather info
var finalResponse = await chatClient.GetResponseAsync(messages, options);
Chat Client Tool Calling Single Turn
using var client = GetAuthorizedClient();
IChatClient chatClient = client;
var getWeatherTool = AIFunctionFactory.Create(
(string location) => $"The weather in {location} is sunny, 72°F",
"GetWeather",
"Gets the current weather for a location");
var response = await chatClient.GetResponseAsync(
[new ChatMessage(ChatRole.User, "What's the weather in Seattle?")],
new ChatOptions
{
ModelId = "jamba-large",
Tools = [getWeatherTool],
});
var functionCall = response.Messages
.SelectMany(m => m.Contents)
.OfType<FunctionCallContent>()
.FirstOrDefault();
Chat Client Tool Calling Streaming
using var client = GetAuthorizedClient();
IChatClient chatClient = client;
var getWeatherTool = AIFunctionFactory.Create(
(string location) => $"The weather in {location} is sunny, 72°F",
"GetWeather",
"Gets the current weather for a location");
var updates = chatClient.GetStreamingResponseAsync(
[new ChatMessage(ChatRole.User, "What's the weather in Seattle?")],
new ChatOptions
{
ModelId = "jamba-large",
Tools = [getWeatherTool],
});
var functionCalls = new List<FunctionCallContent>();
await foreach (var update in updates)
{
functionCalls.AddRange(update.Contents.OfType<FunctionCallContent>());
}
Test
using var api = GetAuthorizedClient();
// await api.Completion.V1J2UltraCompleteAsync(
// messages:
// [
// new ChatMessage
// {
// Text = "Hello",
// Role = RoleType.User,
// }
// ],
// system: string.Empty,
// cancellationToken: CancellationToken.None);
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/AI21/issues
Priority place for ideas and general questions: https://github.com/tryAGI/AI21/discussions
Discord: https://discord.gg/Ca2xhfBf3v
Acknowledgments
This project is supported by JetBrains through the Open Source Support Program.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.AI.Abstractions (>= 10.6.0)
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 |
|---|---|---|
| 0.1.0 | 456 | 8/1/2023 |
| 0.0.0-dev.281 | 58 | 8/29/2026 |
| 0.0.0-dev.279 | 188 | 6/17/2026 |
| 0.0.0-dev.278 | 83 | 6/16/2026 |
| 0.0.0-dev.277 | 63 | 5/21/2026 |
| 0.0.0-dev.275 | 71 | 5/7/2026 |
| 0.0.0-dev.264 | 88 | 4/1/2026 |
| 0.0.0-dev.261 | 89 | 3/29/2026 |
| 0.0.0-dev.260 | 78 | 3/29/2026 |
| 0.0.0-dev.255 | 166 | 3/28/2026 |
| 0.0.0-dev.253 | 89 | 3/28/2026 |
| 0.0.0-dev.252 | 79 | 3/28/2026 |
| 0.0.0-dev.251 | 80 | 3/28/2026 |
| 0.0.0-dev.250 | 88 | 3/27/2026 |
| 0.0.0-dev.242 | 85 | 3/20/2026 |
| 0.0.0-dev.239 | 82 | 3/20/2026 |
| 0.0.0-dev.237 | 90 | 3/20/2026 |
| 0.0.0-dev.236 | 76 | 3/19/2026 |
| 0.0.0-dev.234 | 75 | 3/19/2026 |
| 0.0.0-dev.232 | 85 | 3/19/2026 |