MistralSDK.Net
5.0.0
dotnet add package MistralSDK.Net --version 5.0.0
NuGet\Install-Package MistralSDK.Net -Version 5.0.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="MistralSDK.Net" Version="5.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MistralSDK.Net" Version="5.0.0" />
<PackageReference Include="MistralSDK.Net" />
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 MistralSDK.Net --version 5.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MistralSDK.Net, 5.0.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 MistralSDK.Net@5.0.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=MistralSDK.Net&version=5.0.0
#tool nuget:?package=MistralSDK.Net&version=5.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Mistral AI SDK for .NET

A simple and powerful .NET SDK for the Mistral AI API.
Features • Quick Start • Documentation • License
Features
- Chat completion API with full parameter support
- Agents API - Run completions with pre-configured agents
- Models API - List, retrieve, update, archive fine-tuned models
- Embeddings - Text (mistral-embed) and code (codestral-embed) embeddings for RAG
- FIM - Fill-in-the-middle code completion (Codestral)
- Batch API - Asynchronous batch inference for chat, embeddings, FIM, etc.
- Fine-Tuning - Create and manage fine-tuning jobs
- Classifiers - Moderation and classification (text & chat)
- Reasoning - Chain-of-thought with Magistral models (math, coding)
- Audio & Transcription - Transcribe audio to text (Voxtral models)
- OCR / Document AI - Extract text from PDFs and images
- Files API - Upload, list, download files for OCR/fine-tuning/audio
- Streaming responses with
IAsyncEnumerable - All Mistral models (Large, Small, Codestral, Pixtral...)
- JSON mode and JSON Schema support
- Stop sequences, penalties, and sampling controls
- Async/await with cancellation support
- Dependency Injection ready
- Custom exception handling
- Response caching
Installation
dotnet add package MistralSDK.Net
Quick Start
using MistralSDK;
using MistralSDK.ChatCompletion;
var apiKey = Environment.GetEnvironmentVariable("MISTRAL_API_KEY");
using var client = new MistralClient(apiKey);
var request = new ChatCompletionRequest
{
Model = MistralModels.Small,
Messages = new List<MessageRequest>
{
new MessageRequest { Role = MessageRoles.User, Content = "Hello!" }
}
};
var response = await client.ChatCompletionAsync(request);
if (response.IsSuccess)
{
Console.WriteLine(response.Message);
}
OCR (Extract text from documents)
using MistralSDK;
using var stream = File.OpenRead("document.pdf");
var text = await client.OcrExtractTextAsync(stream, "document.pdf");
Console.WriteLine(text);
For document Q&A with conversation history:
using MistralSDK.Workflows;
var qa = new DocumentQa(client);
await qa.LoadDocumentAsync(File.OpenRead("contract.pdf"), "contract.pdf");
Console.WriteLine(await qa.AskAsync("What is the termination clause?"));
Multi-Turn Conversation
using MistralSDK.Conversation;
var session = new ChatSession(client) { SystemPrompt = "You are a helpful assistant." };
session.AddUser("What is the capital of France?");
Console.WriteLine(await session.CompleteAsync());
session.AddUser("And what's the population?");
Console.WriteLine(await session.CompleteAsync());
Streaming
await foreach (var chunk in client.ChatCompletionStreamAsync(request))
{
Console.Write(chunk.GetContent());
}
Dependency Injection
builder.Services.AddMistralClient(options =>
{
options.ApiKey = builder.Configuration["MistralApi:ApiKey"];
});
Available Models
| Constant | Description |
|---|---|
MistralModels.Large |
Flagship model, top-tier reasoning |
MistralModels.Small |
Good balance of speed and quality |
MistralModels.Ministral8B |
Efficient for edge deployment |
MistralModels.Codestral |
Optimized for code generation |
Documentation
Requirements
- .NET 8.0+
- Mistral AI API key (Get one here)
License
MIT License - see LICENSE for details.
| 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 was computed. 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 was computed. 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.
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.