跳到主要內容

影片生成

影片生成為非同步任務:先提交任務取得任務 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-your-token" \
-d '{
"model": "sora-2",
"prompt": "An orange cat rolling in the snow, slow motion",
"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": "An orange cat rolling in the snow, slow motion",
"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-your-token"

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-your-token" \
--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-your-token" \
-d '{
"model": "kling-v1",
"prompt": "Shuttles flying over a cyberpunk city",
"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-your-token"
{
"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 為暫時網址,完成後請盡快轉存。