快速开始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 chatPOST /v1/chat/completions最适合作为第一条请求Best suited for your first request
图片生成Image generationPOST /v1/images/generations文生图 / 图生图Text-to-image / image-to-image
语音合成Speech synthesisPOST /v1/audio/speech文本转语音Text-to-speech
语音转写Speech transcriptionPOST /v1/audio/transcriptions音频文件识别Audio file recognition
视频生成Video generationPOST /v1/videos/generations异步任务,提交后轮询查询Async task; poll for results after submission
模型列表ModelsGET /v1/models查询当前密钥可调用的模型List models callable with the current key

基础信息Basic Information

配置项Item值Value
API Base URL{BASE_URL}/v1
认证方式AuthenticationAuthorization: Bearer <平台Token>
聊天端点Chat endpointPOST /v1/chat/completions
图片端点Image endpointPOST /v1/images/generations
视频端点Video endpointPOST /v1/videos/generations

发送第一个同步请求Send Your First Synchronous Request

最简单的方式是先用 cURL 调用统一聊天接口:The simplest way is to call the unified chat endpoint with cURL first:

quickstart.shcURL
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

openai.pyPython
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

openai.jsNode.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:

switch-model.pyPython
# 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: set stream: true in the chat request. See API Reference → Streaming Output.
  • 需要切换厂商:保持请求结构不变,只改 model。Switching providers: keep the request structure unchanged and change only model.
  • 需要生成图片:改用 POST /v1/images/generations。Image generation: use POST /v1/images/generations instead.
  • 需要生成视频:改用 POST /v1/videos/generations,异步轮询查询,见「视频生成」模块。Video generation: use POST /v1/videos/generations with async polling. See the Video Generation module.

下一步Next Steps