Semantic Kernel 可以通过其 OpenAI 自定义端点聊天补全服务调用 TokenLab。
类型: SDK / 代理框架主要路径: OpenAI 兼容的聊天补全 (chat completions)支持置信度: 支持自定义端点路径
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
.NET Kernel Builder
Semantic Kernel 的自定义端点应指向 OpenAI 兼容的根端点 /v1,而不是 /v1/chat/completions。
using Microsoft.SemanticKernel;
#pragma warning disable SKEXP0010
var builder = Kernel.CreateBuilder();
builder.AddOpenAIChatCompletion(
modelId: "gpt-5.4-mini",
endpoint: new Uri("https://api.tokenlab.sh/v1"),
apiKey: Environment.GetEnvironmentVariable("TOKENLAB_API_KEY"));
var kernel = builder.Build();
基础 Prompt
var result = await kernel.InvokePromptAsync(
"Give me a concise checklist for evaluating an LLM gateway.");
Console.WriteLine(result);
端点注意事项
使用:
https://api.tokenlab.sh/v1
请勿使用:
https://api.tokenlab.sh/v1/chat/completions
对于此连接器,Semantic Kernel 会在内部自动附加聊天补全路径。