本平台提供兼容 OpenAI 格式的 API 网关服务,支持文本对话(Chat Completions)、视频生成(Seedance 1.5-pro / 2.0)和图片生成(Seedream 5.0-lite)三大能力。 所有接口均通过 API Key 鉴权,可直接替换 OpenAI SDK 的 base_url 使用。
所有 API 请求(除公开模型列表外)均需在请求头中携带 API Key。API Key 可在控制台 → API Keys页面创建和管理。
Authorization: Bearer sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
from openai import OpenAI
client = OpenAI(
api_key="sk_your_api_key",
base_url="https://llm-proxy.tejarvis.info/api/v1"
)
response = client.chat.completions.create(
model="doubao-pro-32k",
messages=[{"role": "user", "content": "Hello"}]
)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk_your_api_key",
baseURL: "https://llm-proxy.tejarvis.info/api/v1",
});
const res = await client.chat.completions.create({
model: "doubao-pro-32k",
messages: [{ role: "user", content: "Hello" }],
});所有错误响应均返回标准 JSON 格式,包含 error 对象。
{
"error": {
"type": "authentication_error",
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}| HTTP 状态 | error.code | 说明 |
|---|---|---|
| 401 | MISSING_API_KEY | 请求头中未携带 API Key |
| 401 | INVALID_API_KEY | API Key 无效或已被撤销 |
| 402 | INSUFFICIENT_BALANCE | 账户余额不足,请充值 |
| 400 | MISSING_MODEL | 请求体中缺少 model 字段 |
| 400 | INVALID_MESSAGES | messages 格式不正确 |
| 400 | MISSING_PROMPT | 缺少 prompt 字段 |
| 400 | WRONG_ENDPOINT | 模型不支持该接口(如视频模型调用了 chat/completions) |
| 404 | MODEL_NOT_FOUND | 指定的模型不存在 |
| 503 | MODEL_UNAVAILABLE | 模型暂时不可用 |
| 500 | INTERNAL_ERROR | 服务器内部错误 |
平台按实际使用量计费,费用从账户余额中实时扣除。不同类型的请求计费方式不同。
发送对话消息,获取模型回复。兼容 OpenAI Chat Completions API 格式,支持流式输出(SSE)和多模态(图片)输入。
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| model | string | 必填 | — | 模型 ID,如 doubao-pro-32k。可通过 GET /api/v1/models 获取可用列表。 |
| messages | array | 必填 | — | 对话消息数组,每条消息包含 role(system/user/assistant)和 content 字段。 |
| stream | boolean | 可选 | false | 是否开启流式输出。为 true 时以 Server-Sent Events(SSE)格式返回,每个 chunk 格式为 data: {...}\n\n。 |
| temperature | number | 可选 | 1.0 | 采样温度,范围 0-2。值越高输出越随机,值越低输出越确定。 |
| max_tokens | integer | 可选 | — | 生成的最大 token 数量。不设置则使用模型默认值。 |
| top_p | number | 可选 | 1.0 | 核采样概率,范围 0-1。与 temperature 二选一调整。 |
content 字段支持字符串(纯文本)或数组(多模态,含图片):
// 纯文本消息
{ "role": "user", "content": "请介绍一下量子计算" }
// 多模态消息(图片 + 文字)
{
"role": "user",
"content": [
{ "type": "image_url", "image_url": { "url": "https://example.com/image.jpg" } },
{ "type": "text", "text": "这张图片里有什么?" }
]
}curl -X POST https://llm-proxy.tejarvis.info/api/v1/chat/completions \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-pro-32k",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello, world!" }
],
"temperature": 0.7,
"max_tokens": 1024
}'{
"id": "chatcmpl-xxxxxxxxxxxx",
"object": "chat.completion",
"created": 1710000000,
"model": "doubao-pro-32k",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 12,
"total_tokens": 32
}
}data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"delta":{"role":"assistant","content":"Hello"},"index":0}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"delta":{"content":"!"},"index":0}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"delta":{},"finish_reason":"stop","index":0}]}
data: [DONE]返回平台当前可用的所有模型。需要 API Key 认证。公开版本(无需认证)请访问 GET /api/v1/models/public。
curl https://llm-proxy.tejarvis.info/api/v1/models \ -H "Authorization: Bearer sk_your_api_key"
{
"object": "list",
"data": [
{
"id": "doubao-pro-32k",
"object": "model",
"created": 1710000000,
"owned_by": "volcengine",
"description": "豆包 Pro 32K 上下文模型"
},
{
"id": "doubao-seedance-1-5-pro-251215",
"object": "model",
"created": 1710000000,
"owned_by": "volcengine",
"description": "Seedance 1.5 Pro 视频生成模型"
}
]
}视频生成为异步接口。提交任务后返回 request_id, 通过轮询任务状态接口获取生成结果。支持四种任务类型,可选择是否生成音频。
异步提交视频生成任务,立即返回任务 ID。任务通常在 30 秒至 5 分钟内完成,请通过查询接口轮询状态。
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| model | string | 可选 | doubao-seedance-1-5-pro-251215 | 模型 ID。可选值:doubao-seedance-1-5-pro-251215(1.5-pro)、doubao-seedance-2-0(2.0) |
| prompt | string | 必填 | — | 视频内容描述文本。建议详细描述场景、动作、风格等,支持中英文。 |
| task_type | string | 可选 | text_to_video | 任务类型:text_to_video(文生视频)、image_to_video(图生视频)、text_to_audio_video(文生音画)、image_to_audio_video(图生音画) |
| image_url | string | 可选 | — | 参考图片 URL。当 task_type 为 image_to_video 或 image_to_audio_video 时必填。 |
| resolution | string | 可选 | 720p | 输出分辨率:480p(854×480)、720p(1280×720)、1080p(1920×1080)、adaptive(自适应) |
| duration | integer | 可选 | 5 | 视频时长(秒),范围 4-12。时长越长费用越高。 |
| generate_audio | boolean | 可选 | — | 是否生成音频。若不设置,则由 task_type 自动推断(含 audio 的类型默认为 true)。 |
| seed | integer | 可选 | — | 随机种子,用于复现生成结果。 |
| watermark | boolean | 可选 | — | 是否添加水印。 |
| service_tier | string | 可选 | default | 服务等级:default(在线推理,即时响应)、flex(批量推理,价格减半,响应较慢) |
text_to_video:仅需 prompt,生成无声视频image_to_video:需要 prompt + image_url,以图片为起始帧生成无声视频text_to_audio_video:仅需 prompt,生成有声视频(含 AI 配音)image_to_audio_video:需要 prompt + image_url,生成有声视频# 文生视频(720p,5秒,无声)
curl -X POST https://llm-proxy.tejarvis.info/api/v1/videos/generations \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-1-5-pro-251215",
"task_type": "text_to_video",
"prompt": "一只橙色的猫咪在阳光下慵懒地伸懒腰,背景是温馨的客厅",
"resolution": "720p",
"duration": 5
}'# 图生音画(以图片为参考,生成有声视频)
curl -X POST https://llm-proxy.tejarvis.info/api/v1/videos/generations \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2-0",
"task_type": "image_to_audio_video",
"prompt": "人物开始微笑并向镜头挥手",
"image_url": "https://example.com/portrait.jpg",
"resolution": "720p",
"duration": 5
}'{
"id": "vreq_AbCdEfGhIjKlMnOpQrSt",
"task_id": "7483920174839201",
"status": "pending",
"model": "doubao-seedance-1-5-pro-251215",
"created": 1710000000,
"object": "video.generation.task"
}通过提交任务时返回的 request_id 查询任务当前状态。建议每 5-10 秒轮询一次,直到状态变为 succeeded 或 failed。
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| :id | string | 必填 | — | 提交任务时返回的 request_id(以 vreq_ 开头) |
curl https://llm-proxy.tejarvis.info/api/v1/videos/tasks/vreq_AbCdEfGhIjKlMnOpQrSt \ -H "Authorization: Bearer sk_your_api_key"
// 生成中
{
"id": "vreq_AbCdEfGhIjKlMnOpQrSt",
"task_id": "7483920174839201",
"status": "processing",
"model": "doubao-seedance-1-5-pro-251215",
"prompt": "一只橙色的猫咪...",
"resolution": "720p",
"duration": 5,
"generate_audio": false,
"task_type": "text_to_video",
"total_cost": "0",
"created_at": "2024-03-10T08:00:00.000Z"
}
// 生成成功
{
"id": "vreq_AbCdEfGhIjKlMnOpQrSt",
"status": "succeeded",
"video_url": "https://cdn.example.com/videos/output.mp4",
"thumbnail_url": "https://cdn.example.com/thumbnails/cover.jpg",
"total_cost": "0.8640",
"completed_at": "2024-03-10T08:01:23.000Z"
}| status | 说明 |
|---|---|
| pending | 任务已提交,等待处理 |
| processing | 任务正在生成中 |
| succeeded | 生成成功,video_url 字段包含视频链接 |
| failed | 生成失败,error 字段包含错误原因 |
import time
import requests
API_KEY = "sk_your_api_key"
BASE_URL = "https://llm-proxy.tejarvis.info/api"
headers = {"Authorization": f"Bearer {API_KEY}"}
# 1. 提交任务
resp = requests.post(f"{BASE_URL}/v1/videos/generations", headers=headers, json={
"model": "doubao-seedance-1-5-pro-251215",
"task_type": "text_to_video",
"prompt": "日落时分,海浪轻拍礁石",
"resolution": "720p",
"duration": 5,
})
task = resp.json()
request_id = task["id"]
print(f"任务已提交: {request_id}")
# 2. 轮询状态
while True:
status_resp = requests.get(
f"{BASE_URL}/v1/videos/tasks/{request_id}",
headers=headers
)
data = status_resp.json()
status = data.get("status")
print(f"当前状态: {status}")
if status == "succeeded":
print(f"视频链接: {data['video_url']}")
break
elif status == "failed":
print(f"生成失败: {data.get('error')}")
break
time.sleep(5) # 每5秒轮询一次获取当前 API Key 所属账户的视频生成任务列表,按创建时间倒序排列。
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| limit | integer | 可选 | 20 | 返回条数,最大 100 |
| offset | integer | 可选 | 0 | 分页偏移量 |
curl "https://llm-proxy.tejarvis.info/api/v1/videos/tasks?limit=10&offset=0" \ -H "Authorization: Bearer sk_your_api_key"
{
"object": "list",
"data": [
{
"id": "vreq_AbCdEfGhIjKlMnOpQrSt",
"status": "succeeded",
"model": "doubao-seedance-1-5-pro-251215",
"task_type": "text_to_video",
"prompt": "一只橙色的猫咪...",
"resolution": "720p",
"duration": 5,
"generate_audio": false,
"video_url": "https://cdn.example.com/videos/output.mp4",
"total_cost": "0.8640",
"created_at": "2024-03-10T08:00:00.000Z",
"completed_at": "2024-03-10T08:01:23.000Z"
}
]
}图片生成为同步接口,请求后直接返回图片 URL 数组。支持文生图和图生图两种模式, 单次最多生成 4 张图片。
同步接口,直接返回生成结果。图片生成通常需要 5-30 秒,请设置足够长的超时时间(建议 120 秒)。
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| model | string | 可选 | doubao-seedream-5-0-260128 | 模型 ID,当前支持 doubao-seedream-5-0-260128 |
| prompt | string | 必填 | — | 图片内容描述文本。支持中英文,建议详细描述主体、风格、光线、构图等。 |
| task_type | string | 可选 | text_to_image | 任务类型:text_to_image(文生图)、image_to_image(图生图) |
| negative_prompt | string | 可选 | — | 负向提示词,描述不希望出现的内容,如 "模糊、低质量、水印" |
| image_url | string | 可选 | — | 参考图片 URL。当 task_type 为 image_to_image 时必填,模型将基于此图片进行风格迁移或内容修改。 |
| size | string | 可选 | 2048x2048 | 输出图片尺寸,最小 3686400 像素。支持:2048x2048(1:1)、2560x1440(16:9)、1440x2560(9:16)、2560x1920(4:3)、1920x2560(3:4)、2400x1600(3:2)、3840x2160(4K) |
| style | string | 可选 | — | 图片风格。支持:anime(动漫)、realistic(写实)、oil_painting(油画)、watercolor(水彩)、sketch(素描)等 |
| n | integer | 可选 | 1 | 生成图片数量,范围 1-4。每张独立计费(¥0.18/张)。 |
| seed | integer | 可选 | — | 随机种子,设置后可复现相同结果。设为 -1 表示随机。 |
| output_format | string | 可选 | png | 输出格式:png、jpg、webp |
# 文生图(1024x1024,动漫风格,生成2张)
curl -X POST https://llm-proxy.tejarvis.info/api/v1/images/generations \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"task_type": "text_to_image",
"prompt": "一个穿着汉服的少女站在樱花树下,柔和的春日光线,精致的面部特写",
"negative_prompt": "模糊, 低质量, 变形, 水印",
"size": "1024x1024",
"style": "anime",
"n": 2
}'# 图生图(基于参考图片生成写实风格)
curl -X POST https://llm-proxy.tejarvis.info/api/v1/images/generations \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"task_type": "image_to_image",
"prompt": "将图片风格转换为水彩画,保留主体构图",
"image_url": "https://example.com/photo.jpg",
"size": "1024x1024",
"style": "watercolor"
}'{
"request_id": "img-1710000000000-AbCdEf",
"model": "doubao-seedream-5-0-260128",
"image_urls": [
"https://cdn.example.com/images/output-1.png",
"https://cdn.example.com/images/output-2.png"
],
"total_cost": 0.36
}import requests
API_KEY = "sk_your_api_key"
BASE_URL = "https://llm-proxy.tejarvis.info/api"
resp = requests.post(
f"{BASE_URL}/v1/images/generations",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "doubao-seedream-5-0-260128",
"task_type": "text_to_image",
"prompt": "赛博朋克风格的城市夜景,霓虹灯倒影在雨后的街道上",
"size": "1280x720",
"n": 1,
},
timeout=120,
)
data = resp.json()
for url in data["image_urls"]:
print(f"图片链接: {url}")