> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 Kling 回调 URL

> 在 CometAPI 中配置 Kling 的 `callback_url`，以接收异步视频/图像任务状态更新和结果 payload（从 submitted 到 succeed/failed）。

当你希望使用推送交付而不是纯轮询时，可在 Kling 异步任务中使用 `callback_url`。

## 在哪里使用

* 文生视频和图生视频任务
* 数字人和视频特效任务
* 其他暴露可选 `callback_url` 字段的 Kling 异步路由

## 交付行为

* 每当任务状态发生变化时，Kling 都会向你的回调端点发送请求
* 常见状态包括 `submitted`、`processing`、`succeed` 和 `failed`
* 根据任务类型不同，payload 可能包含 `task_result.images` 或 `task_result.videos`
* 保留手动轮询能力，用于对账、重试或处理遗漏的 webhook

## 集成检查清单

* 使用你可控的 HTTPS 回调端点
* 接受同一 task id 的重复状态更新
* 将 webhook 交付视为异步且最终一致
* 如果你的工作流需要持久化存储，请尽快保存最终资源 URL

```jsonc theme={null}
{
  "task_id": "string",
  "task_status": "string",
  "task_status_msg": "string",
  "created_at": 1722769557708,
  "updated_at": 1722769557708,
  "task_result": {
    "images": [
      {
        "index": 0,
        "url": "https://example.com/generated-image.png"
      }
    ],
    "videos": [
      {
        "id": "string",
        "url": "https://example.com/generated-video.mp4",
        "duration": "5"
      }
    ]
  }
}
```
