ModelSell 文档
视频系列Kling

Kling 3.0 Turbo 任务接口

使用新版异步任务接口调用 Kling 3.0 Turbo 文生视频、图生视频,并通过 /kling/tasks 查询任务。

Kling 3.0 Turbo 使用独立的新版任务接口,不走 /kling/v1/videos/* 路径。创建任务后保存返回的 data.id,或在请求中传入 options.external_task_id 方便业务侧查询。

文生视频:创建任务

POST /kling/text-to-video/kling-3.0-turbo

请求头

Content-Type: application/json
Authorization: Bearer {apikey}

请求体

字段类型必填说明
promptstring文本提示词,可包含正向和负向描述;最长 3072 个字符,建议不超过 2500 个字符
settingsobject输出配置;未传时使用默认值
settings.resolutionstring清晰度:720p1080p;默认 720p
settings.aspect_ratiostring画面比例:16:99:161:1;默认 16:9
settings.durationint视频时长:315 秒的整数;默认 5
optionsobject回调、水印和自定义任务 ID 等通用配置
options.callback_urlstring任务状态变化回调地址
options.external_task_idstring业务自定义任务 ID,单用户下需要唯一
options.watermark_infoobject含水印结果配置,暂不支持自定义水印
options.watermark_info.enabledboolean是否同时生成含水印结果,默认 false

prompt 支持多镜头格式:镜头 n, m, words; 镜头 n, m, words;。最多 6 个、最少 1 个镜头;m 为该镜头时长且不得小于 1 秒,所有镜头时长之和须等于视频总时长;每段 words 最长 512 个字符。

cURL

curl --location "$KLING_BASE_URL/kling/text-to-video/kling-3.0-turbo" \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer {apikey}' \
  --data '{
    "prompt": "A girl sat on the train, looking out the window with a melancholic expression, her head swaying with the train.",
    "options": {
      "callback_url": "https://xxx/callback",
      "watermark_info": {
        "enabled": false
      },
      "external_task_id": ""
    },
    "settings": {
      "duration": 3,
      "resolution": "720p",
      "aspect_ratio": "9:16"
    }
  }'

图生视频:创建任务

POST /kling/image-to-video/kling-3.0-turbo

请求头

Content-Type: application/json
Authorization: Bearer {apikey}

请求体

字段类型必填说明
contentsarray提示词、首帧图等参考素材合集
contents[].typestring素材类型:promptfirst_frame
contents[].textstring条件必填type=prompt 时必填,文本提示词不超过 2500 个字符
contents[].urlstring条件必填type=first_frame 时必填,支持图片 URL 或 Base64
settingsobject输出配置;未传时使用默认值
settings.resolutionstring清晰度:720p1080p;默认 720p
settings.durationint视频时长:315 秒的整数;默认 5
optionsobject回调、水印和自定义任务 ID 等通用配置
options.callback_urlstring任务状态变化回调地址
options.external_task_idstring业务自定义任务 ID,单用户下需要唯一
options.watermark_infoobject含水印结果配置,暂不支持自定义水印
options.watermark_info.enabledboolean是否同时生成含水印结果,默认 false

首帧图片支持 .jpg.jpeg.png,文件不得超过 50 MB;宽高均不得小于 300 px,宽高比须在 1:2.52.5:1 之间。目前仅支持首帧,不支持首帧加尾帧或仅尾帧。

cURL

curl --location "$KLING_BASE_URL/kling/image-to-video/kling-3.0-turbo" \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer {apikey}' \
  --data-raw '{
    "contents": [
      {
        "type": "prompt",
        "text": "A girl sat on the train, looking out the window with a melancholic expression, her head swaying with the train."
      },
      {
        "type": "first_frame",
        "url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-tob-release_note/image_25.png"
      }
    ],
    "settings": {
      "resolution": "1080p",
      "duration": 10
    },
    "options": {
      "callback_url": "https://xxx/callback",
      "external_task_id": "",
      "watermark_info": {
        "enabled": true
      }
    }
  }'

创建任务响应

文生视频和图生视频创建成功后均返回任务基础信息:

{
  "code": 0,
  "message": "string",
  "request_id": "string",
  "data": {
    "id": "893605946402811985",
    "status": "submitted",
    "create_time": 1781080778802,
    "update_time": 1781080794151,
    "external_id": "string"
  }
}

查询任务(指定任务 ID)

请求方式路径查询参数
GET/kling/taskstask_idsexternal_task_ids

task_idsexternal_task_ids 至少且只能传一种,支持用英文逗号批量查询。

curl "$KLING_BASE_URL/kling/tasks?external_task_ids=order-10001" \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer $KLING_API_KEY"

查询任务(按游标查询)

请求方式路径
POST/kling/tasks
curl --location "$KLING_BASE_URL/kling/tasks" \
  --header "Content-Type: application/json" \
  --header "Authorization: Bearer $KLING_API_KEY" \
  --data '{
    "start_time": "1781193600000",
    "end_time": "1781516352968",
    "cursor": "",
    "limit": 500,
    "filters": [
      {
        "key": "status",
        "values": ["succeeded"]
      },
      {
        "key": "product_type",
        "values": ["video"]
      }
    ]
  }'

游标查询返回 data.resultdata.next_cursordata.has_more,可用 next_cursor 继续翻页。

On this page