Skip to content

Callback Protocol

Other parameters

See the official documentation at https://app.klingai.com/cn/dev/document-api/apiReference/updateNotice. The parameters are the same; when integrating, you only need to change the request domain and API key to ours.

Async task callback protocol

For asynchronous tasks (image generation / video generation), if you set callback_url when creating the task, the server will actively send a notification when the task status changes.

Callback payload format

json
{
  "task_id": "string",           // 任务ID,系统生成
  "task_status": "string",       // 任务状态
  "task_status_msg": "string",   // 任务状态信息
  "created_at": 1722769557708,   // 任务创建时间(Unix时间戳,单位ms)
  "updated_at": 1722769557708,   // 任务更新时间(Unix时间戳,单位ms)
  "task_result": {
    "images": [                  // 图片类任务的结果
      {
        "index": 0,             // 图片编号,0-9
        "url": "string"         // 生成图片的URL
      }
    ],
    "videos": [                 // 视频类任务的结果
      {
        "id": "string",         // 视频ID,全局唯一
        "url": "string",        // 视频的URL
        "duration": "string"    // 视频总时长,单位s
      }
    ]
  }
}

Task status

Possible values for task_status:

  • submitted: Submitted
  • processing: Processing
  • succeed: Succeeded
  • failed: Failed

Notes

  • When a task fails, task_status_msg shows the failure reason (e.g. platform content moderation triggered)
  • Example image URL: https://h1.inkwai.com/bs2/upload-ylab-stunt/1fa0ac67d8ce6cd55b50d68b967b3a59.png