快速开始Quick Start
5 分钟内完成第一条请求,并知道后续该从哪里继续扩展。Complete your first request within 5 minutes and know where to expand next.
前提条件Prerequisites
- 一个平台账号,登录控制台后即可使用。A platform account — log in to the console to use it.
- 已创建的 API Key,在「令牌」页面创建。An API Key created on the Token page.
- 账户有可用余额,首次使用可先充值。Available balance in your account — top up before first use if needed.
先选接入方式Choose Your Access Method First
平台提供统一的 OpenAI 兼容接口,按能力选择对应端点即可:The platform provides a unified OpenAI-compatible interface; just pick the endpoint that matches your use case:
| 场景Scenario | 推荐接口Recommended Endpoint | 说明Description |
|---|---|---|
| 默认文本对话Default text chat | POST /v1/chat/completions | 最适合作为第一条请求Best suited for your first request |
| 图片生成Image generation | POST /v1/images/generations | 文生图 / 图生图Text-to-image / image-to-image |
| 语音合成Speech synthesis | POST /v1/audio/speech | 文本转语音Text-to-speech |
| 语音转写Speech transcription | POST /v1/audio/transcriptions | 音频文件识别Audio file recognition |
| 视频生成Video generation | POST /v1/videos/generations | 异步任务,提交后轮询查询Async task; poll for results after submission |
| 模型列表Models | GET /v1/models | 查询当前密钥可调用的模型List models callable with the current key |
基础信息Basic Information
| 配置项Item | 值Value |
|---|---|
| API Base URL | {BASE_URL}/v1 |
| 认证方式Authentication | Authorization: Bearer <平台Token> |
| 聊天端点Chat endpoint | POST /v1/chat/completions |
| 图片端点Image endpoint | POST /v1/images/generations |
| 视频端点Video endpoint | POST /v1/videos/generations |
发送第一个同步请求Send Your First Synchronous Request
最简单的方式是先用 cURL 调用统一聊天接口:The simplest way is to call the unified chat endpoint with cURL first:
curl {BASE_URL}/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{ "role": "user", "content": "你好,请介绍一下你自己" }]
}'
如果这条请求成功,就说明你的账号、密钥和网络都已打通。If this request succeeds, your account, key, and network are all set up correctly.
使用 SDKUsing the SDK
平台完全兼容 OpenAI SDK,只需修改 base_url 即可。The platform is fully compatible with the OpenAI SDK — just change the base_url.
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="{BASE_URL}/v1",
)
completion = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "你好,请介绍一下你自己"}],
)
print(completion.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "{BASE_URL}/v1",
});
const completion = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "你好,请介绍一下你自己" }],
});
console.log(completion.choices[0].message.content);
切换模型Switching Models
平台的核心优势之一是能够在不同厂商的模型之间自由切换,只需更改 model 参数,请求结构保持不变:One of the platform's core advantages is switching freely between models from different providers — just change the model parameter and keep the request structure unchanged:
# Use the default model
resp = client.chat.completions.create(model="gpt-4o", messages=[...])
# Switch to another model — just change the model parameter
resp = client.chat.completions.create(model="claude-3-5-sonnet", messages=[...])
resp = client.chat.completions.create(model="gemini-2.0-flash", messages=[...])
GET /v1/models 查询。The models you can actually call are determined by the current key's permissions and what the Model Square displays; query them in the Model Square or via GET /v1/models.常见扩展Common Extensions
- 需要流式输出:在聊天请求里设置
stream: true,见「API 参考 → 流式输出」。Streaming output: setstream: truein the chat request. See API Reference → Streaming Output. - 需要切换厂商:保持请求结构不变,只改
model。Switching providers: keep the request structure unchanged and change onlymodel. - 需要生成图片:改用
POST /v1/images/generations。Image generation: usePOST /v1/images/generationsinstead. - 需要生成视频:改用
POST /v1/videos/generations,异步轮询查询,见「视频生成」模块。Video generation: usePOST /v1/videos/generationswith async polling. See the Video Generation module.
下一步Next Steps
- 认证鉴权Authentication — 了解 API Key 和请求头的详细说明。 — Learn the details of API Keys and request headers.
- API 参考API Reference — 查看统一聊天接口完整参数与响应。 — View the full parameters and responses of the unified chat endpoint.
- 模型与能力Models & Capabilities — 按能力选择接口,查看可用模型。 — Choose endpoints by capability and view available models.
- 视频生成Video Generation — 查看视频请求模板与模型选择。 — View video request templates and model selection.