认证鉴权Authentication
所有 API 请求都需要通过 API Key 进行身份认证。调用平台代理地址时,统一使用 Authorization: Bearer YOUR_API_KEY。All API requests must be authenticated with an API Key. When calling the platform proxy endpoint, always use Authorization: Bearer YOUR_API_KEY.
获取 API KeyGet an API Key
登录控制台Log In to the Console
使用账号登录平台控制台。Log in to the platform console with your account.
进入令牌页面Go to the Token Page
在「令牌」页面点击「添加令牌」。On the Token page, click Add Token.
创建并保存Create and Save
按需设置名称、额度与模型范围,复制生成的 Key 并妥善保存。Set the name, quota, and model scope as needed, then copy the generated key and keep it safe.
认证方式总览Authentication Overview
平台对外统一使用 Bearer 认证,所有接口使用同一个平台 Token:The platform uses Bearer authentication externally, and all endpoints share the same platform Token:
| 接口Endpoint | 认证方式Authentication | 说明Description |
|---|---|---|
POST /v1/chat/completions | Authorization: Bearer <Token> | OpenAI 兼容聊天接口OpenAI-compatible chat endpoint |
POST /v1/images/generations | Authorization: Bearer <Token> | 图片生成Image generation |
POST /v1/audio/speech | Authorization: Bearer <Token> | 语音合成Speech synthesis |
POST /v1/videos/generations | Authorization: Bearer <Token> | 视频生成(异步)Video generation (async) |
GET /v1/models | Authorization: Bearer <Token> | 模型列表Models |
Bearer 认证Bearer Authentication
在请求的 Authorization Header 中携带平台 Token:Include the platform Token in the Authorization header of your request:
curl {BASE_URL}/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxx" \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "你好"}]}'
请求头说明Request Headers
| 请求头Header | 必填Required | 类型Type | 说明Description |
|---|---|---|---|
Authorization | 是Yes | string | 格式为 Bearer YOUR_API_KEY,用于身份认证Format: Bearer YOUR_API_KEY, used for authentication |
Content-Type | 是Yes | string | 固定为 application/jsonAlways application/json |
Request-Id
你可以在请求头中传入自定义的 Request-Id,用于请求追踪与问题排查:You can pass a custom Request-Id in the request header for request tracing and troubleshooting:
curl {BASE_URL}/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Request-Id: your-unique-request-id-123" \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "你好"}]}'
在 SDK 中使用Using with SDKs
Python(OpenAI SDK)Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="{BASE_URL}/v1",
)
Node.js(OpenAI SDK)Node.js (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "{BASE_URL}/v1",
});
常见认证错误Common Authentication Errors
| 状态码Status Code | 说明Description | 解决方法Solution |
|---|---|---|
| 401 | API Key 无效或缺失The API Key is invalid or missing | 检查 Header 中是否正确携带了 AuthorizationCheck that the Authorization header is properly included |
| 403 | 权限不足Insufficient permissions | 检查 Token 是否有访问对应模型的权限,或模型是否已配置价格Check whether the Token has permission to access the model, or whether the model has pricing configured |
| 429 | 余额不足或请求过于频繁Insufficient balance or too many requests | 充值后恢复调用,或降低请求频率Top up your balance to resume calls, or reduce the request rate |
下一步Next Steps
- 快速开始Quick Start — 先打通第一条请求。 — Get your first request through.
- 模型与能力Models & Capabilities — 了解平台支持的模型与能力边界。 — Learn about the models supported by the platform and their capability boundaries.
- 视频生成Video Generation — 查看视频接口的异步调用方式。 — See how to call the video endpoints asynchronously.