概览Overview
平台提供统一的模型调用入口。本文档用于解释「该怎么接入、怎么选接口、哪些行为需要注意」;API 参考只保留具体接口、请求字段和响应结构。The platform provides a unified entry point for model calls. This document explains how to get connected, how to choose the right endpoint, and which behaviors to watch out for; the API Reference keeps only concrete endpoints, request fields, and response structures.
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": "你好"}
]
}'
先选择调用路径Choose Your Call Path First
| 目标Goal | 推荐接口Recommended Endpoint | 适合场景Use Case |
|---|---|---|
| 统一文本对话Unified text chat | POST /v1/chat/completions | 默认入口,适合 OpenAI、Claude、Gemini 等聊天模型Default entry point for chat models such as OpenAI, Claude, and Gemini |
| 图片生成Image generation | POST /v1/images/generations | 文生图、图生图等图片创作场景Image creation scenarios such as text-to-image and image-to-image |
| 图片编辑Image editing | POST /v1/images/edits | 基于参考图修改与局部编辑Modify and locally edit based on a reference image |
| 语音合成Speech synthesis | POST /v1/audio/speech | 文本转语音与播报音频生成Text-to-speech and broadcast audio generation |
| 语音转写Speech transcription | POST /v1/audio/transcriptions | 音频文件识别与文本提取Recognize audio files and extract text |
| 视频生成Video generation | POST /v1/videos/generations | 异步文生视频、图生视频,结果通过任务 ID 查询下载Async text-to-video and image-to-video; results are queried and downloaded by task ID |
| 模型列表Models | GET /v1/models | 查询当前密钥可调用的模型List models callable with the current key |
指南与参考怎么分工How Guides and Reference Divide the Work
- 本「概览」及右侧各模块解释认证、参数、流式输出、错误排查与计费等使用要点。This Overview and the modules beside it explain usage essentials such as authentication, parameters, streaming output, error troubleshooting, and billing.
- 「API 参考」只描述具体 endpoint 的 method、path、headers、request body、response body 和错误形态。The API Reference describes only the method, path, headers, request body, response body, and error shapes of each concrete endpoint.
- 「视频生成」集中说明异步视频任务的提交、查询与计费。Video Generation focuses on submitting, querying, and billing async video tasks.
- 「计费与配额」说明各模型类型的计费方式、余额充值与消费记录。Billing & Quota explains billing methods by model type, balance top-ups, and consumption records.
常用指南Common Guides
认证鉴权Authentication
了解 API Key、Bearer Token 与安全建议,见「API 参考 → 鉴权」。Learn about the API Key, Bearer Token, and security best practices. See API Reference → Authentication.
通用参数Common Parameters
理解 model、messages、temperature、response_format、tools 等常用字段。Understand common fields such as model, messages, temperature, response_format, and tools.
流式输出Streaming Output
设置 stream: true 实现逐段返回,降低首字延迟。Set stream: true to stream responses segment by segment and reduce time to first token.
视频生成Video Generation
异步任务模式:提交 → 轮询 → 下载,详见「视频生成」模块。Async task mode: submit → poll → download. See the Video Generation module for details.
计费与配额Billing & Quota
按 Token / 按张 / 按秒 / 积分 / 按字符,详见「计费与配额」模块。Per token / per image / per second / per credit / per character. See the Billing & Quota module for details.
错误排查Error Troubleshooting
401 / 403 / 404 / 429 / 5xx 的含义与处理建议,见「API 参考 → 错误码」。Meanings and handling tips for 401 / 403 / 404 / 429 / 5xx. See API Reference → Error Codes.
三步开始调用Get Started in 3 Steps
创建 API KeyCreate an API Key
登录控制台,在「令牌」页面创建密钥,并按需设置额度与访问范围。Log in to the console, create a key on the Token page, and set quota and access scope as needed.
配置客户端Configure the Client
将客户端 Base URL 设置为 {BASE_URL}/v1。Set the client Base URL to {BASE_URL}/v1.
发送请求Send a Request
使用 OpenAI SDK 或任意 HTTP 客户端调用平台已授权模型。Call authorized models using the OpenAI SDK or any HTTP client.
客户端 SDK 示例Client SDK Examples
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="{BASE_URL}/v1",
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "{BASE_URL}/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "你好" }],
});
console.log(resp.choices[0].message.content);
model 字段即可切换不同模型;视频生成采用异步任务模式,提交后返回 task_id,轮询查询接口直至 succeeded 后再取 result_url 下载视频。Keep the request structure unchanged and simply change the model field to switch models. Video generation uses an async task mode: a task_id is returned after submission; poll the query endpoint until the status is succeeded, then fetch result_url to download the video.下一步Next Steps
- 快速开始Quick Start — 5 分钟内发送你的第一个 API 请求。 — Send your first API request in 5 minutes.
- 认证鉴权Authentication — 了解如何认证你的 API 请求。 — Learn how to authenticate your API requests.
- API 参考API Reference — 查看各接口的请求字段与响应结构。 — View request fields and response structures for each endpoint.
- 模型与能力Models & Capabilities — 按能力选择接口,并查看可用模型。 — Choose endpoints by capability and view available models.
- 视频生成Video Generation — 调用视频模型并了解异步返回方式与计费说明。 — Call video models and learn about async results and billing.
- 计费与配额Billing & Quota — 了解计费方式、充值与消费记录。 — Learn about billing methods, top-ups, and consumption records.
- 工具集成Tool Integration — 在 Claude Code、Cursor 等工具中配置接入。 — Configure access in tools such as Claude Code and Cursor.