API Documentation
完全兼容 OpenAI SDK,修改一行 base_url 即可迁移。
Base URL
https://www.joapiai.xin/v1
Authentication
在请求头中传入 API Key:
Authorization: Bearer sk-your-api-key
可用模型
| Model ID | 说明 | 输入 | 输出 | 特性 |
|---|---|---|---|---|
doubao-seed-2-0-mini |
高速低延迟,高频场景 | $0.14/M | $0.69/M | 🧠 🖼️ 🎬 |
doubao-seed-2-0-lite |
均衡生产主力 | $0.39/M | $1.99/M | 🧠 🖼️ 🎬 ⭐ |
doubao-seed-2-0-code |
AI 编程专用 | $1.49/M | $6.99/M | 🧠 💻 🖼️ |
🧠 深度思考 🖼️ 图片理解 🎬 视频理解 💻 编程加强
所有模型均支持 256k 上下文。 查看模型对比 →
POST /v1/chat/completions
完全兼容 OpenAI SDK,支持流式和非流式。
cURL
curl https://www.joapiai.xin/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seed-2-0-lite",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'
Python (openai SDK)
from openai import OpenAI
client = OpenAI(
api_key="sk-your-key",
base_url="https://www.joapiai.xin/v1"
)
# Non-streaming
resp = client.chat.completions.create(
model="doubao-seed-2-0-lite",
messages=[{"role": "user", "content": "Write a haiku about the ocean"}]
)
print(resp.choices[0].message.content)
# Streaming
for chunk in client.chat.completions.create(
model="doubao-seed-2-0-mini",
messages=[{"role": "user", "content": "Count to 5"}],
stream=True
):
print(chunk.choices[0].delta.content or "", end="", flush=True)
🧠 reasoning_effort — 深度思考控制
所有 Doubao Seed 2.0 模型均支持 4 档思考深度,默认不开启思考。
minimal
不思考,最快速
low
浅度推理
medium
均衡推理(推荐)
high
深度推理,最强效果
resp = client.chat.completions.create(
model="doubao-seed-2-0-lite",
messages=[{"role": "user", "content": "Solve: 3x + 5 = 20"}],
extra_body={"reasoning_effort": "medium"} # minimal | low | medium | high
)
print(resp.choices[0].message.content)
注:thinking token 已计入输出 token 计费。
🖼️ 图片 / 视频理解
在 messages 的 content 里传入 image_url,格式与 OpenAI Vision 完全一致。
resp = client.chat.completions.create(
model="doubao-seed-2-0-lite",
messages=[{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}},
{"type": "text", "text": "What is in this image?"}
]
}]
)
print(resp.choices[0].message.content)
💻 接入 Claude Code / Cursor / Cline
doubao-seed-2-0-code 可直接替代 Claude Sonnet,接入主流 AI 编程工具,价格是 Claude Sonnet 的 1/2。
Claude Code
# ~/.claude/settings.json
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-your-joapi-key",
"ANTHROPIC_BASE_URL": "https://www.joapiai.xin/v1",
"ANTHROPIC_MODEL": "doubao-seed-2-0-code"
}
}
Cursor / Cline / OpenAI-compatible tools
Base URL : https://www.joapiai.xin/v1
API Key : sk-your-joapi-key
Model : doubao-seed-2-0-code
GET /v1/models
curl https://www.joapiai.xin/v1/models \
-H "Authorization: Bearer sk-your-key"
错误码
| Code | 含义 |
|---|---|
401 | API Key 无效或缺失 |
402 | 余额不足,请充值 |
429 | 频率超限(10秒1次)或月度配额耗尽 |
451 | 内容违规,已记录 |
400 | 请求格式错误(未知模型、参数无效) |
502 | 上游 API 错误 |