视频生成
视频生成是异步任务:先提交任务得到任务 ID,再轮询查询状态,完成后下载视频。网关同时支持两种格式:
| 格式 | 提交 | 查询 | 说明 |
|---|---|---|---|
| OpenAI Sora 格式 | POST /v1/videos | GET /v1/videos/{video_id} | 标准 Sora API 形态 |
| 通用任务格式 | POST /v1/video/generations | GET /v1/video/generations/{task_id} | NewAPI 通用视频任务 |
Sora 格式
提交任务
POST /v1/videoscurl https://test.kailin.com.cn/v1/videos \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的令牌" \
-d '{
"model": "sora-2",
"prompt": "一只橘猫在雪地里打滚,慢镜头",
"seconds": "10",
"size": "1280x720"
}'
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 视频模型,如 sora-2、sora-2-pro |
prompt | string | 是 | 画面描述 |
seconds | string | 否 | 时长(如 "4" / "8" / "12",视模型而定) |
size | string | 否 | 分辨率,如 1280x720 / 720x1280 |
input_reference | file | 否 | 参考图/首帧(multipart 传参时使用) |
响应(任务对象)
{
"id": "video_abc123",
"object": "video",
"created_at": 1730000000,
"status": "queued",
"model": "sora-2",
"prompt": "一只橘猫在雪地里打滚,慢镜头",
"size": "1280x720",
"seconds": "10",
"progress": 0
}
查询任务
GET /v1/videos/{video_id}curl https://test.kailin.com.cn/v1/videos/video_abc123 \
-H "Authorization: Bearer sk-你的令牌"
status 状态流转:queued → in_progress → completed / failed,进行中时 progress 为 0–100。
下载视频
GET /v1/videos/{video_id}/content任务 completed 后下载 MP4 二进制:
curl "https://test.kailin.com.cn/v1/videos/video_abc123/content" \
-H "Authorization: Bearer sk-你的令牌" \
--output result.mp4
通用任务格式
提交任务
POST /v1/video/generationscurl https://test.kailin.com.cn/v1/video/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的令牌" \
-d '{
"model": "kling-v1",
"prompt": "赛博朋克城市上空的飞行器穿梭",
"duration": 5
}'
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 视频模型名(以模型列表为准) |
prompt | string | 是 | 画面描述 |
image_url | string | 否 | 图生视频的首帧图地址 |
duration / size 等 | - | 否 | 其余参数按模型透传(时长、分辨率、比例等) |
响应
{ "task_id": "4f6a2b1c-xxxx-xxxx-xxxx" }
查询任务
GET /v1/video/generations/{task_id}curl https://test.kailin.com.cn/v1/video/generations/4f6a2b1c-xxxx \
-H "Authorization: Bearer sk-你的令牌"
{
"task_id": "4f6a2b1c-xxxx",
"status": "SUCCESS",
"video_url": "https://oss.example.com/video/xxx.mp4",
"progress": "100%"
}
| 字段 | 说明 |
|---|---|
status | 任务状态(SUBMITTED / IN_PROGRESS / SUCCESS / FAILURE,视渠道而定) |
video_url / url | 生成结果地址(字段名视渠道而定) |
progress | 进度 |
警告
视频生成耗时从几十秒到数分钟不等,请设置 10–30 秒的轮询间隔,并为任务 ID 做持久化(网关任务记录有保留期限)。video_url 为临时地址,完成后请尽快转存。