Appearance
视频生成任务
视频生成使用异步任务接口:创建任务后返回 video_task_*,客户端通过查询接口轮询状态和结果。接口使用 API Key 鉴权,不使用控制台 JWT。
text
Base URL: https://llm.xiaoyue9527.xyz/v1
Authorization: Bearer sk-gtw-REPLACE_ME
Content-Type: application/json接口列表
| 接口 | 方法 | 用途 |
|---|---|---|
/v1/video/generations/tasks | POST | 创建视频生成任务 |
/v1/video/generations/tasks/{task_id} | GET | 查询单个任务 |
/v1/video/generations/tasks | GET | 查询任务列表 |
/v1/video/generations/tasks/{task_id}/cancel | POST | 取消任务 |
/v1/video/generations/tasks/{task_id} | DELETE | 取消任务 |
兼容短路径:/v1/video/tasks、/v1/video/tasks/{task_id} 和 /v1/video/tasks/{task_id}/cancel。
创建任务
创建任务必须提供幂等键,推荐使用 Idempotency-Key。也可以使用 X-Request-ID 请求头或请求体里的 request_id;优先级依次为 Idempotency-Key、X-Request-ID、request_id。失败重试时必须复用同一个键和相同请求体。
bash
curl -X POST https://llm.xiaoyue9527.xyz/v1/video/generations/tasks \
-H 'Authorization: Bearer sk-gtw-REPLACE_ME' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: biz-video-20260707-0001' \
-d '{
"model": "seedance-2-0-fast",
"content": [
{
"type": "text",
"text": "A calm 3 second cinematic shot of a blue glass cube on a clean white desk."
}
],
"duration": 3,
"ratio": "16:9",
"resolution": "720p",
"watermark": false
}'请求体会按模型路由转发给上游视频供应商。平台固定识别 model、request_id、content、duration / duration_seconds / seconds,其他字段会尽量原样透传给上游。
查询任务
bash
curl 'https://llm.xiaoyue9527.xyz/v1/video/generations/tasks/video_task_xxx?refresh=true' \
-H 'Authorization: Bearer sk-gtw-REPLACE_ME'非终态任务查询时会同步上游状态;终态任务如需强制再次同步,可传 refresh=true。
成功任务会在 content.video_url 返回视频结果链接:
json
{
"id": "video_task_xxx",
"object": "video.generation.task",
"created": 1783000000,
"updated": 1783000010,
"model": "seedance-2-0-fast",
"status": "succeeded",
"content": {
"video_url": "https://example.com/video.mp4"
},
"usage": {
"completion_tokens": 108900,
"total_tokens": 108900
},
"billing": {
"status": "settled",
"billing_event_id": "8f3c...",
"estimated_cost_units": 500000000,
"user_cost_units": 108900000,
"promo_credit_used_units": 0,
"paid_credit_used_units": 0,
"wallet_charged_units": 108900000
}
}字段说明
| 字段 | 说明 |
|---|---|
id | 平台视频任务 ID |
status | creating / queued / running / cancelling / succeeded / failed / cancelled / expired / unknown |
content.video_url | 成功后的视频结果链接 |
usage | 上游返回的 usage 原文 |
billing.status | pending / reserved / settled / not_charged |
billing.estimated_cost_units | 创建任务时用于额度预占的预估费用,不是最终扣费 |
billing.user_cost_units | 结算后的客户实际费用;存在时应优先用于展示和对账 |
billing.promo_credit_used_units / billing.paid_credit_used_units / billing.wallet_charged_units | 结算后的赠金、付费包、钱包扣费拆分 |
金额字段使用平台统一高精度单位:1 元 = 100,000,000 units。任务创建时返回的预估费用用于预算预占,终态任务应以 billing.user_cost_units 为准。not_charged 表示终态任务未产生扣费,此时不要把预估值展示为实际费用。
列表和取消
查询列表:
bash
curl 'https://llm.xiaoyue9527.xyz/v1/video/generations/tasks?limit=20&status=succeeded&model=seedance-2-0-fast&scope=api_key' \
-H 'Authorization: Bearer sk-gtw-REPLACE_ME'列表参数:
| 参数 | 默认值 | 说明 |
|---|---|---|
from | 当前时间前 24 小时 | RFC3339 起始时间 |
to | 当前时间 | RFC3339 结束时间;时间窗最长 31 天 |
status | 空 | 按任务状态过滤 |
model | 空 | 按模型 ID 过滤 |
scope | api_key | api_key 仅当前 Key;account 查询当前账号下任务 |
limit | 50 | 每页数量,最大 100 |
after | 空 | 使用上一页 next_cursor 继续分页 |
列表响应包含 object: "list"、data、has_more,还有下一页时会返回 next_cursor:
json
{
"object": "list",
"data": [],
"has_more": true,
"next_cursor": "cursor_xxx"
}取消任务:
bash
curl -X POST https://llm.xiaoyue9527.xyz/v1/video/generations/tasks/video_task_xxx/cancel \
-H 'Authorization: Bearer sk-gtw-REPLACE_ME'终态任务重复取消会直接返回当前任务。
限制和错误
| 项 | 说明 |
|---|---|
| 请求体大小 | 最大 4 MiB |
| 单个字符串字段 | 最大 2 MiB |
内联 data:*;base64 素材 | 最大 512 KiB;建议改用对象存储 URL |
| 列表时间窗 | 最大 31 天 |
| 活跃任务限制 | 超限返回 429 video_task_limit_exceeded |
常见错误包括 idempotency_key_required、idempotency_conflict、insufficient_quota、budget_exceeded、model_not_found、task_not_found、request_too_large。