跳到正文
GitHub·· 5 天前AI 评分18

soenneker.mistral.openapiclient:用于 .NET 调用 Mistral API 的类型化客户端

soenneker/soenneker.mistral.openapiclient

AI 导读

soenneker.mistral.openapiclient 发布,为 .NET 提供调用 Mistral API 的类型化请求构建器与模型,可通过 dotnet add package Soenneker.Mistral.OpenApiClient 安装。

正文

Typed request builders and models for calling the Mistral API from .NET.

Installation

dotnet add package Soenneker.Mistral.OpenApiClient

Usage

using System.Net.Http.Headers;
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using Soenneker.Mistral.OpenApiClient;

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);

var adapter = new HttpClientRequestAdapter(
    new AnonymousAuthenticationProvider(),
    httpClient: httpClient);

var client = new MistralOpenApiClient(adapter);
var models = await client.V1.Models.GetAsync(cancellationToken: cancellationToken);

The generated client defaults to https://api.mistral.ai. Set adapter.BaseUrl before constructing MistralOpenApiClient to use another endpoint.

For application registration, configuration-based credentials, and managed client reuse, use Soenneker.Mistral.OpenApiClientUtil.

来源:GitHub · github.com