Framework & platform
Semantic Kernel
Hubungkan Microsoft Semantic Kernel ke TokenLab dengan endpoint yang kompatibel dengan OpenAI
Gambaran Umum
Semantic Kernel dapat memanggil TokenLab melalui layanan penyelesaian chat endpoint kustom OpenAI-nya.
Lingkungan
export TOKENLAB_API_KEY="sk-your-tokenlab-key".NET Kernel Builder
Endpoint kustom Semantic Kernel harus mengarah ke root endpoint /v1 yang kompatibel dengan OpenAI, bukan /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 Dasar
var result = await kernel.InvokePromptAsync(
"Give me a concise checklist for evaluating an LLM gateway.");
Console.WriteLine(result);Catatan Endpoint
Gunakan:
https://api.tokenlab.sh/v1Jangan gunakan:
https://api.tokenlab.sh/v1/chat/completionsSemantic Kernel menambahkan path chat completions secara otomatis untuk konektor ini.