跳到主要内容

视频生成

视频生成是异步任务:先提交任务得到任务 ID,再轮询查询状态,完成后下载视频。网关同时支持两种格式:

格式提交查询说明
OpenAI Sora 格式POST /v1/videosGET /v1/videos/{video_id}标准 Sora API 形态
通用任务格式POST /v1/video/generationsGET /v1/video/generations/{task_id}NewAPI 通用视频任务

Sora 格式​

提交任务​

POST /v1/videos
curl 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"
}'
参数类型必填说明
modelstring是视频模型,如 sora-2、sora-2-pro
promptstring是画面描述
secondsstring否时长(如 "4" / "8" / "12",视模型而定)
sizestring否分辨率,如 1280x720 / 720x1280
input_referencefile否参考图/首帧(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/generations
curl https://test.kailin.com.cn/v1/video/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的令牌" \
-d '{
"model": "kling-v1",
"prompt": "赛博朋克城市上空的飞行器穿梭",
"duration": 5
}'
参数类型必填说明
modelstring是视频模型名(以模型列表为准)
promptstring是画面描述
image_urlstring否图生视频的首帧图地址
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 为临时地址,完成后请尽快转存。