| name | klingai-webhook-config |
| description | Configure webhook callbacks for Kling AI task completion. Use when building event-driven
pipelines or replacing polling. Trigger with phrases like 'klingai webhook', 'kling ai callback',
'klingai notifications', 'video completion webhook'.
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.18.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kling-ai","webhooks","callbacks"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Kling AI Webhook Configuration
Overview
Instead of polling task status, pass a callback_url when creating a task. Kling AI will POST the completed task result to your URL when generation finishes. This eliminates polling overhead and reduces API calls.
Supported on: All video generation endpoints (text2video, image2video, video-extend, lip-sync, effects)
How It Works
- Include
callback_url in your task creation request
- Kling queues the task normally
- When task reaches terminal state (
succeed or failed), Kling POSTs the full result to your URL
- Your webhook handler processes the result
Sending a Task with Callback
import jwt, time, os, requests
BASE = "https://api.klingai.com/v1"
def get_headers():
ak, sk = os.environ["KLING_ACCESS_KEY"], os.environ["KLING_SECRET_KEY"]
token = jwt.encode(
{"iss": ak, "exp": int(time.time()) + 1800, "nbf": int(time.time()) - 5},
sk, algorithm="HS256", headers={"alg": "HS256", "typ": "JWT"}
)
return {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
"model_name": "kling-v2-master",
"prompt": ,
: ,
: ,
: ,
})
task_id = response.json()[][]
()