Mistral.SDK
1.2.0
See the version list below for details.
dotnet add package Mistral.SDK --version 1.2.0
NuGet\Install-Package Mistral.SDK -Version 1.2.0
<PackageReference Include="Mistral.SDK" Version="1.2.0" />
<PackageVersion Include="Mistral.SDK" Version="1.2.0" />
<PackageReference Include="Mistral.SDK" />
paket add Mistral.SDK --version 1.2.0
#r "nuget: Mistral.SDK, 1.2.0"
#:package Mistral.SDK@1.2.0
#addin nuget:?package=Mistral.SDK&version=1.2.0
#tool nuget:?package=Mistral.SDK&version=1.2.0
Mistral.SDK
Mistral.SDK is an unofficial C# client designed for interacting with the Mistral API. This powerful interface simplifies the integration of Mistral AI into your C# applications. It targets netstandard2.0, and .net6.0.
Table of Contents
Installation
Install Mistral.SDK via the NuGet package manager:
PM> Install-Package Mistral.SDK
API Keys
You can load the API Key from an environment variable named MISTRAL_API_KEY by default. Alternatively, you can supply it as a string to the MistralClient constructor.
IHttpClientFactory
The MistralClient can optionally take an IHttpClientFactory, which allows you to control elements such as retries and timeouts.
Usage
To start using the Mistral API, simply create an instance of the MistralClient class.
Examples
Non-Streaming Call
Here's an example of a non-streaming call to the mistral-medium completions endpoint (other options are available and documented, but omitted for brevity):
var client = new MistralClient();
var client = new MistralClient();
var request = new ChatCompletionRequest(
//define model - required
ModelDefinitions.MistralMedium,
//define messages - required
new List<ChatMessage>()
{
new ChatMessage(ChatMessage.RoleEnum.System,
"You are an expert at writing sonnets."),
new ChatMessage(ChatMessage.RoleEnum.User,
"Write me a sonnet about the Statue of Liberty.")
},
//optional - defaults to false
safePrompt: true,
//optional - defaults to 0.7
temperature: 0,
//optional - defaults to null
maxTokens: 500,
//optional - defaults to 1
topP: 1,
//optional - defaults to null
randomSeed: 32);
var response = await client.Completions.GetCompletionAsync(request);
Console.WriteLine(response.Choices.First().Message.Content);
Streaming Call
The following is an example of a streaming call to the mistral-medium completions endpoint:
var client = new MistralClient();
var request = new ChatCompletionRequest(
ModelDefinitions.MistralMedium,
new List<ChatMessage>()
{
new ChatMessage(ChatMessage.RoleEnum.System,
"You are an expert at writing sonnets."),
new ChatMessage(ChatMessage.RoleEnum.User,
"Write me a sonnet about the Statue of Liberty.")
});
var results = new List<ChatCompletionResponse>();
await foreach (var res in client.Completions.StreamCompletionAsync(request))
{
results.Add(res);
Console.Write(res.Choices.First().Delta.Content);
}
List Models
The following is an example of a call to list the available models:
var client = new MistralClient();
var response = await client.Models.GetModelsAsync();
Embeddings
The following is an example of a call to the mistral-embed embeddings model/endpoint:
var client = new MistralClient();
var request = new EmbeddingRequest(
ModelDefinitions.MistralEmbed,
new List<string>() { "Hello world" },
EmbeddingRequest.EncodingFormatEnum.Float);
var response = await client.Embeddings.GetEmbeddingsAsync(request);
Contributing
Pull requests are welcome. If you're planning to make a major change, please open an issue first to discuss your proposed changes.
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 7.0.0)
- System.Text.Json (>= 6.0.7)
-
net6.0
- Microsoft.Extensions.Http (>= 7.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Mistral.SDK:
| Package | Downloads |
|---|---|
|
fAI
Fred's experimentation with AI |
|
|
Indiko.Blocks.AI.Mistral
Building Blocks AI Mistral |
|
|
Mistral.TaskTextGenerator
Генератор текстов задач на базе публичного API клиента к нейросети Mistral. генерирует тексты задач на русском и представляет из себя класс в котором есть метод собирающий строку запроса к нейросети на основе значений параметров |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Mistral.SDK:
| Repository | Stars |
|---|---|
|
getcellm/cellm
Use LLMs in Excel formulas
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.1 | 1,880 | 10/20/2025 |
| 2.3.0 | 1,365 | 9/23/2025 |
| 2.2.0 | 15,849 | 5/16/2025 |
| 2.1.3 | 316 | 5/15/2025 |
| 2.1.2 | 1,193 | 5/9/2025 |
| 2.1.1 | 9,228 | 3/19/2025 |
| 2.1.0 | 4,034 | 2/21/2025 |
| 2.0.1 | 8,758 | 1/16/2025 |
| 2.0.0 | 8,044 | 12/2/2024 |
| 1.3.3 | 309 | 11/27/2024 |
| 1.3.2 | 1,369 | 11/22/2024 |
| 1.3.1 | 1,972 | 11/13/2024 |
| 1.3.0 | 2,549 | 10/31/2024 |
| 1.2.1 | 18,192 | 5/18/2024 |
| 1.2.0 | 12,894 | 2/26/2024 |
| 1.1.0 | 1,066 | 1/16/2024 |
| 1.0.1 | 820 | 12/26/2023 |
| 1.0.0 | 346 | 12/15/2023 |
Adopts latest models as defaults in predefined models and updates to include Mistral-Large.