框架与平台
Semantic Kernel
通过自定义 OpenAI 兼容端点将 Microsoft Semantic Kernel 连接到 TokenLab
概述
Semantic Kernel 的 OpenAI 自定义地址聊天服务可以调用 TokenLab。
环境
export TOKENLAB_API_KEY="sk-your-tokenlab-key".NET Kernel Builder
自定义地址填写 TokenLab /v1,不要填写完整的 /v1/chat/completions。
using Microsoft.SemanticKernel;
#pragma warning disable SKEXP0010
var builder = Kernel.CreateBuilder();
builder.AddOpenAIChatCompletion(
modelId: "gpt-5.6-luna",
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/completionsSemantic Kernel 会自动在这个 Base URL 后添加 Chat Completions 路径。