影片生成
影片生成為非同步任務:先提交任務取得任務 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-your-token" \
-d '{
"model": "sora-2",
"prompt": "An orange cat rolling in the snow, slow motion",
"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": "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/generationscurl 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
}'
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
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-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 為暫時網址,完成後請盡快轉存。