框架与平台
Portkey Gateway
把 Portkey Gateway 连接到 TokenLab
概述
在 Portkey 中将 TokenLab 配置为自定义 OpenAI 兼容服务。只有当前 Portkey 版本支持自定义 Responses 地址时,才使用 Responses。
配置值
| 字段 | 值 |
|---|---|
| Provider | openai |
| Custom Host | https://api.tokenlab.sh/v1 |
| API 密钥 | sk-your-tokenlab-key |
| 模型 | 当前 TokenLab 模型 ID |
Chat Completions
使用 TokenLab 进行 OpenAI 兼容的聊天请求:
此示例需要已运行的自托管 Portkey Gateway,请将网关 URL 替换为你的部署地址。使用 Portkey Cloud 时,还需通过 x-portkey-api-key 发送 Portkey API 密钥。参见 Portkey 配置指南。
curl https://your-portkey-gateway.example/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-portkey-provider: openai" \
-H "x-portkey-custom-host: https://api.tokenlab.sh/v1" \
-H "Authorization: Bearer sk-your-tokenlab-key" \
-d '{
"model": "gpt-5.6-luna",
"messages": [{"role": "user", "content": "Say hello from TokenLab."}]
}'Responses
如果当前 Portkey 版本支持自定义 Responses 地址,请从模型页选择支持 Responses 的模型,并使用 /v1/responses。
其他 API 格式
Anthropic Messages 和 Gemini 格式能否通过 Portkey 使用,取决于当前 Portkey 版本是否支持自定义对应地址。