using System.Net.Http.Headers; using Admin.NET.Core.Ai.Option; namespace Admin.NET.Core.Ai.Handlers; public class LLMDelegatingHandler: DelegatingHandler { private readonly LLMCustomOptions _options; public LLMDelegatingHandler(IOptions options) { _options = options.Value; } protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { //设置header request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _options.ApiKey); return await base.SendAsync(request, cancellationToken); } }