- Fully generated C# SDK based on official Mistral 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
- Microsoft.Extensions.AI
IChatClientsupport
using Mistral;
using var client = new MistralClient(apiKey);
ChatCompletionResponse response = await client.Agents.AgentsCompletionAsync(
agentId: "Test",
messages: new List<OneOf<UserMessage, AssistantMessage, ToolMessage>>
{
new UserMessage
{
Content = "Hello",
},
});The SDK implements IChatClient for seamless integration with the .NET AI ecosystem:
using Mistral;
using Meai = Microsoft.Extensions.AI;
Meai.IChatClient chatClient = new MistralClient(apiKey);
var response = await chatClient.GetResponseAsync(
[new Meai.ChatMessage(Meai.ChatRole.User, "Hello!")],
new Meai.ChatOptions { ModelId = "mistral-large-latest" });
Console.WriteLine(response.Text);Note: Use the
Meaialias because the Mistral SDK has its own generatedIChatClientinterface.
using var client = new MistralClient(apiKey);
Meai.IChatClient chatClient = client;
var updates = chatClient.GetStreamingResponseAsync(
[
new Meai.ChatMessage(Meai.ChatRole.User, "Generate 5 random words.")
],
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
});
var deltas = new List<string>();
await foreach (var update in updates)
{
if (!string.IsNullOrWhiteSpace(update.Text))
{
deltas.Add(update.Text);
}
}using var client = new MistralClient(apiKey);
Meai.IChatClient chatClient = client;
var response = await chatClient.GetResponseAsync(
[
new Meai.ChatMessage(Meai.ChatRole.User, "Generate 5 random words.")
],
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
});using var client = CreateTestClient();
Meai.IChatClient chatClient = client;
var metadata = Meai.ChatClientExtensions.GetService<Meai.ChatClientMetadata>(chatClient);using var client = CreateTestClient();
Meai.IChatClient chatClient = client;
var result = Meai.ChatClientExtensions.GetService<Meai.ChatClientMetadata>(chatClient, serviceKey: "unknown");using var client = CreateTestClient();
Meai.IChatClient chatClient = client;
var self = Meai.ChatClientExtensions.GetService<MistralClient>(chatClient);using var client = new MistralClient(apiKey);
var getWeatherTool = Meai.AIFunctionFactory.Create(
(string location) => $"The weather in {location} is 72°F and sunny.",
name: "get_weather",
description: "Gets the current weather for a given location.");
Meai.IChatClient chatClient = client;
var messages = new List<Meai.ChatMessage>
{
new(Meai.ChatRole.User, "What is the weather in Paris?"),
};
// First turn: model requests tool call
var response = await chatClient.GetResponseAsync(
messages,
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
Tools = [getWeatherTool],
});
var functionCall = response.Messages
.SelectMany(m => m.Contents)
.OfType<Meai.FunctionCallContent>()
.FirstOrDefault();
// Add assistant message with function call and tool result
messages.AddRange(response.Messages);
var toolResult = await getWeatherTool.InvokeAsync(
functionCall!.Arguments is { } args ? new Meai.AIFunctionArguments(args) : null);
messages.Add(new Meai.ChatMessage(Meai.ChatRole.Tool,
[
new Meai.FunctionResultContent(functionCall.CallId, toolResult),
]));
// Second turn: model should produce a final text response
var finalResponse = await chatClient.GetResponseAsync(
messages,
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
Tools = [getWeatherTool],
});using var client = new MistralClient(apiKey);
var getWeatherTool = Meai.AIFunctionFactory.Create(
(string location) => $"The weather in {location} is 72°F and sunny.",
name: "get_weather",
description: "Gets the current weather for a given location.");
Meai.IChatClient chatClient = client;
var response = await chatClient.GetResponseAsync(
[
new Meai.ChatMessage(Meai.ChatRole.User, "What is the weather in Paris?")
],
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
Tools = [getWeatherTool],
});
var functionCall = response.Messages
.SelectMany(m => m.Contents)
.OfType<Meai.FunctionCallContent>()
.FirstOrDefault();using var client = new MistralClient(apiKey);
var getWeatherTool = Meai.AIFunctionFactory.Create(
(string location) => $"The weather in {location} is 72°F and sunny.",
name: "get_weather",
description: "Gets the current weather for a given location.");
Meai.IChatClient chatClient = client;
var updates = chatClient.GetStreamingResponseAsync(
[
new Meai.ChatMessage(Meai.ChatRole.User, "What is the weather in Paris?")
],
new Meai.ChatOptions
{
ModelId = "mistral-small-latest",
Tools = [getWeatherTool],
});
var functionCalls = new List<Meai.FunctionCallContent>();
await foreach (var update in updates)
{
functionCalls.AddRange(update.Contents.OfType<Meai.FunctionCallContent>());
}using var client = new MistralClient(apiKey);
ChatCompletionResponse response = await client.Agents.AgentsCompletionAsync(
agentId: "Test",
messages: new List<MessagesItem3>
{
new UserMessage
{
Content = "Hello",
},
});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.
Priority place for bugs: https://github.com/tryAGI/Mistral/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Mistral/discussions
Discord: https://discord.gg/Ca2xhfBf3v
This project is supported by JetBrains through the Open Source Support Program.
