GitHub·· 7 天前AI 评分12
Soenneker.Mistral.HttpClients:为 Mistral API 提供带缓存的认证 HttpClient
soenneker/soenneker.mistral.httpclients
AI 导读
Soenneker.Mistral.HttpClients 是一个 .NET 包,为 Mistral API 提供带缓存的认证 HttpClient,可通过 dotnet add package 安装。
正文
Provides a cached, authenticated HttpClient for the Mistral API.
Installation
dotnet add package Soenneker.Mistral.HttpClients
Configuration
{
"Mistral": {
"ApiKey": "your-api-key"
}
}Mistral:ClientBaseUrl can override the default https://api.mistral.ai endpoint. Mistral:AuthHeaderName and Mistral:AuthHeaderValueTemplate can override the default Authorization: Bearer {token} header.
Usage
using Soenneker.Mistral.HttpClients.Abstract; using Soenneker.Mistral.HttpClients.Registrars; services.AddMistralOpenApiHttpClientAsSingleton(); IMistralOpenApiHttpClient mistral = serviceProvider .GetRequiredService<IMistralOpenApiHttpClient>(); HttpClient client = await mistral.Get(cancellationToken);
Do not dispose the returned HttpClient; the registered provider owns it. Disposing the provider removes the cached client.
来源:GitHub · github.com