GitHub·· 6 天前AI 评分12
Soenneker.Mistral.OpenApiClientUtil:为 .NET 提供配置好的 Mistral API 客户端
soenneker/soenneker.mistral.openapiclientutil
AI 导读
Soenneker.Mistral.OpenApiClientUtil 是一个 .NET 工具包,提供已配置好的 Mistral API 客户端,并在注册服务生命周期内复用该客户端。
正文
Provides a configured Mistral API client and reuses it for the lifetime of the registered service.
Installation
dotnet add package Soenneker.Mistral.OpenApiClientUtil
Configuration
{
"Mistral": {
"ApiKey": "your-api-key"
}
}Usage
using Soenneker.Mistral.OpenApiClientUtil.Abstract; using Soenneker.Mistral.OpenApiClientUtil.Registrars; services.AddMistralOpenApiClientUtilAsSingleton(); IMistralOpenApiClientUtil mistral = serviceProvider .GetRequiredService<IMistralOpenApiClientUtil>(); var client = await mistral.Get(cancellationToken); var models = await client.V1.Models.GetAsync(cancellationToken: cancellationToken);
Use AddMistralOpenApiClientUtilAsScoped() when each application scope should have its own generated client wrapper. The underlying HTTP provider remains shared and is disposed by the service container at shutdown.
来源:GitHub · github.com