> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Semantic Kernel

> Kết nối Microsoft Semantic Kernel với TokenLab bằng endpoint tùy chỉnh tương thích với OpenAI

## Tổng quan

Semantic Kernel có thể gọi TokenLab thông qua dịch vụ hoàn thiện trò chuyện (chat completion) endpoint tùy chỉnh của OpenAI.

<Note>
  **Loại**: SDK / Framework tác nhân (Agent Framework)

  **Đường dẫn chính**: Hoàn thiện trò chuyện tương thích với OpenAI

  **Độ tin cậy hỗ trợ**: Hỗ trợ đường dẫn endpoint tùy chỉnh
</Note>

## Môi trường

```bash theme={null}
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
```

## .NET Kernel Builder

Endpoint tùy chỉnh của Semantic Kernel nên trỏ đến endpoint gốc `/v1` tương thích với OpenAI, không phải `/v1/chat/completions`.

```csharp theme={null}
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 cơ bản

```csharp theme={null}
var result = await kernel.InvokePromptAsync(
    "Give me a concise checklist for evaluating an LLM gateway.");

Console.WriteLine(result);
```

## Lưu ý về Endpoint

Sử dụng:

```text theme={null}
https://api.tokenlab.sh/v1
```

Không sử dụng:

```text theme={null}
https://api.tokenlab.sh/v1/chat/completions
```

Semantic Kernel sẽ tự động thêm đường dẫn hoàn thiện trò chuyện (chat completions) vào bên trong cho connector này.
