Install-Package TRS.AI.MistralAI
Dotnet SDK for Mistral AI available via Nuget Unofficial. MistralAI doesn't have any official .Net SDK.
For changelogs please go to end of the document.
Your API Key comes from here --> https://mistral.ai/
var aiService = new MistralAIService(new MistralAIOptions()
{
ApiKey = Environment.GetEnvironmentVariable("MISTRAL_API_KEY")
});
"MistralAIServiceOptions": {
//"ApiKey":"Your api key goes here"
}
(How to use user secret ?
Right click your project name in "solution explorer" then click "Manage User Secret", it is a good way to keep your api keys)
serviceCollection.AddMistralAIService();
OR
Use it like below but do NOT put your API key directly to your source code.
serviceCollection.AddMistralAIService(settings => { settings.ApiKey = Environment.GetEnvironmentVariable("MISTRAL_API_KEY"); });
After injecting your service you will be able to get it from service provider
var aiService = serviceProvider.GetRequiredService<IMistralAIService>();
You can set default model(optional):
aiService.SetDefaultModelId(Models.Mistral_Medium);
- Implementation of completion API
- Implementation of embeddings API
- Implementation of models API