跳到主要内容

Kling 图生视频

POST 

/open/aigw/gateway/generations

以输入图片为首帧生成视频,支持首尾帧(一镜到底)模式。支持多个模型版本:2.1 / 2.5 / O1 / 2.6 / 3.0 / 3.0-Omni。

调用流程

  1. 调用本接口提交视频生成任务,获取 taskNo
  2. 系统处理完成后,通过 callbackUrl POST 回调通知结果
  3. 也可通过 GET /open/aigw/gateway/generationTask?taskNo=xxx 轮询查询

Request

Responses

任务提交成功

回调通知格式

生成完成后,系统向 callbackUrl POST 以下数据:

成功时:

{
"taskNo": "a1b2c3d4...",
"status": "success",
"model": "kling_3.0-Omni_img2video",
"timestamp": 1234567890,
"data": {
"task_id": "6928de47-2e53-4ee6-901b-be05a8bf7669",
"status": "SUCCESS",
"request_id": "7d8d7f71a7314779b6947eed659085fa",
"result": ["https://cdn.example.com/result_1.mp4"],
"error_info": "",
"traceback": ""
},
"usage": { "totalPoints": 10 },
"sign": "sha256hex..."
}

失败时:

{
"taskNo": "a1b2c3d4...",
"status": "failed",
"model": "kling_3.0-Omni_img2video",
"timestamp": 1234567890,
"error": "错误信息",
"sign": "sha256hex..."
}

签名验证sign = SHA256(taskNo + timestamp + apiKey)

查询生成任务状态

GET /open/aigw/gateway/generationTask?taskNo={taskNo}

推荐优先使用回调方式,本接口作为轮询兜底。

请求参数:

参数类型必填说明
taskNostring提交任务时返回的任务编号

返回示例(成功):

{
"code": 1000,
"message": "success",
"data": {
"taskNo": "a1b2c3d4...",
"model": "kling_3.0-Omni_img2video",
"status": "success",
"createTime": "2025-01-01 12:00:00",
"data": { "result": ["https://cdn.example.com/result_1.mp4"] },
"usage": { "totalPoints": 10 }
}
}

返回示例(失败):

{
"code": 1000,
"message": "success",
"data": {
"taskNo": "a1b2c3d4...",
"model": "kling_3.0-Omni_img2video",
"status": "failed",
"error": "生成失败原因"
}
}

status 取值: pending(待处理)、processing(处理中)、success(成功)、failed(失败)