Semantic Kernel 可以透過其 OpenAI 自訂端點聊天完成服務(chat completion service)呼叫 TokenLab。
類型: SDK / Agent Framework主要路徑: 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 會在此連接器內部自動附加聊天完成路徑。