> ## 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 callback URLs

> 在 CometAPI 中設定 Kling callback_url，以接收非同步影片/圖片任務狀態更新與結果 payload（從 submitted 到 succeed/failed）。

當你希望使用推送交付，而不是純輪詢時，可在 Kling 非同步任務上使用 `callback_url`。

## 在哪裡使用

* 文字轉影片與圖片轉影片任務
* Avatar 與影片特效任務
* 其他提供可選 `callback_url` 欄位的 Kling 非同步路由

## 交付行為

* 每當任務狀態變更時，Kling 會向你的 callback 端點發送請求
* 常見狀態為 `submitted`、`processing`、`succeed` 和 `failed`
* payload 可依任務類型包含 `task_result.images` 或 `task_result.videos`
* 請保留手動輪詢能力，以便進行對帳、重試或處理遺漏的 webhook

## 整合檢查清單

* 使用你可控管的 HTTPS callback 端點
* 接受同一個 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"
      }
    ]
  }
}
```
