快速开始
- 五分钟完成第一次调用
- 一个 Key 通行文本、图像、视频与音频
- 所有接口与 OpenAI 结构兼容
第一步:创建 API Key
打开 OAIRoute 控制台,点「创建 Key」。复制生成的 sk- 开头的字符串。
Key 只在创建时完整显示一次。没保存的话只能重新创建,旧的记得删除。
Open the OAIRoute console and click "Create key". Copy the sk- string it generates.
The key is shown in full only once, at creation. If you don't save it, you'll have to create a new one — remember to delete the old one.
第二步:跑通第一条请求
curl https://api.oairoute.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_OAIRoute_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "你好"}]
}'返回里有 choices[0].message.content,就是模型的回答。
curl https://api.oairoute.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_OAIRoute_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
}'The response contains choices[0].message.content — the model's answer.
第三步:换成你熟悉的语言
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_OAIRoute_KEY",
base_url="https://api.oairoute.com/v1",
)
res = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "你好"}],
)
print(res.choices[0].message.content)JavaScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_OAIRoute_KEY",
baseURL: "https://api.oairoute.com/v1",
});
const res = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "你好" }],
});
console.log(res.choices[0].message.content);代码里除了 base_url 和 api_key,其他都是标准 OpenAI SDK 的写法。
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_OAIRoute_KEY",
base_url="https://api.oairoute.com/v1",
)
res = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
print(res.choices[0].message.content)JavaScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_OAIRoute_KEY",
baseURL: "https://api.oairoute.com/v1",
});
const res = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);Apart from base_url and api_key, the code is standard OpenAI SDK usage.
两个域名的分工
| 域名 | 覆盖范围 |
|---|---|
https://api.oairoute.com/v1 | 文本对话、任务查询、账户用量 |
https://ark.oairoute.com | 图像生成与编辑、视频生成 |
两个域名用同一个 Key,额度共享。
| Domain | Coverage |
|---|---|
https://api.oairoute.com/v1 | Text chat, task polling, account usage |
https://ark.oairoute.com | Image generation and editing, video generation |
Both domains use the same key and share one balance.
下一步
- 需要流式输出?看「通用对话接口(默认流式)」
- 要出图或出视频?看「图像生成」与「视频生成」
- 不知道怎么接进现有工具?看「接入」
- 报错了?看「常见问题 → 连接与使用问题」
- Need streaming output? See "Chat completions (streaming)"
- Generating images or video? See "Image generation" and "Video generation"
- Not sure how to plug it into an existing tool? See "Integrations"
- Getting an error? See "FAQ → Connection and usage"