> ## 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.

# Portkey Gateway

> 在 Portkey Gateway 中使用 TokenLab 作为上游提供商

## 概述

Portkey Gateway 可以将请求路由至 TokenLab 作为上游提供商。最安全的默认方式是使用 OpenAI 兼容的聊天补全（chat completions）；当您的 Portkey 版本为 TokenLab 开放该路径时，请使用 Responses。

<Note>
  **类型**: AI Gateway

  **主要路径**: OpenAI 兼容的聊天补全和 Responses

  **支持置信度**: 支持的路径
</Note>

## 提供商配置值

| 字段            | 值                            |
| ------------- | ---------------------------- |
| Provider      | `tokenlab`                   |
| Base URL      | `https://api.tokenlab.sh/v1` |
| API key       | `sk-your-tokenlab-key`       |
| Default model | `gpt-5.4-mini`               |

## 聊天补全 (Chat Completions)

使用 TokenLab 进行 OpenAI 兼容的聊天请求：

```bash theme={null}
curl https://your-portkey-gateway.example/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-portkey-provider: tokenlab" \
  -H "Authorization: Bearer sk-your-tokenlab-key" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [{"role": "user", "content": "Say hello from TokenLab."}]
  }'
```

## 响应 (Responses)

如果您的 Portkey 构建版本支持 TokenLab Responses，请使用 `gpt-5.5`、`gpt-5.4` 或 `gpt-5.4-mini` 并配合 `/v1/responses` 路径。

## 原生端点说明

TokenLab 还直接提供了 Anthropic Messages 和 Gemini 兼容的端点。这些端点是否可以通过 Portkey 使用，取决于您所部署版本中 Portkey 对提供商和端点的支持情况。
