admin管理员组文章数量:1291148
I'm trying to set up a Semantic Kernel project and I would like to connect it to the OpenRouter api. To the best of my knowledge, their API should be compatible with the OpenAI API, therefore a connection should work. I used
var httpClient = new HttpClient
{
Timeout = TimeSpan.FromMinutes(10)
};
builder.AddOpenAIChatCompletion(
modelId:"deepseek/deepseek-r1",
apiKey: @"my Open Router Api Key",
endpoint: new Uri(";),
httpClient: httpClient);
I get a 404 error when I try this and I don't know why. When I use the OpenAI API everything works.
I also tried using this HttpClientHandler so that the requests go out to OpenRouter but it didn't work either and I get a 405 error:
public class MyHttpMessageHandler : HttpClientHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.RequestUri != null && request.RequestUri.Host.Equals("api.openai", StringComparison.OrdinalIgnoreCase))
{
request.RequestUri = new Uri($";);
}
return base.SendAsync(request, cancellationToken);
}
}
本文标签: cSemantic Kernel with OpenRouterStack Overflow
版权声明:本文标题:c# - Semantic Kernel with OpenRouter - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741523535a2383330.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论