Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Track and monitor Kling AI video generation task status. Use when building dashboards, tracking batch jobs, or debugging stuck tasks. Trigger with phrases like 'klingai job status', 'kling ai monitor', 'track klingai task', 'klingai progress'.
.claude/skills/jeremylongshore-klingai-job-monitoring/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 33% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 58% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 42% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 7% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 31% | 0% |
Every Kling AI generation returns a task_id. This skill covers polling strategies, batch tracking, timeout handling, and callback-based monitoring for the /v1/videos/text2video, /v1/videos/image2video, and /v1/videos/video-extend endpoints.
| Status | Meaning | Typical Duration | |--------|---------|-----------------| | submitted | Queued for processing | 0-30s | | processing | Generation in progress | 30-120s (standard), 60-300s (professional) | | succeed | Complete, video URL available | Terminal | | failed | Generation failed | Terminal |
pythonimport 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"} def poll_task(endpoint: str, task_id: str, interval: int = 10, timeout: int = 600): """Poll with adaptive interval and timeout.""" start = time.monotonic() attempts = 0 while time.monotonic() - start < timeout: time.sleep(interval) attempts += 1 r = requests.get(f"{BASE}{endpoint}/{task_id}", headers=get_headers(), timeout=30) data = r.json()["data"] status = data["task_status"] elapsed = int(time.monotonic() - start) print(f"[{elapsed}s] Poll #{attempts}: {status}") if status == "succeed": return data["task_result"] elif status == "failed": raise RuntimeError(f"Task failed: {data.get('task_status_msg', 'unknown')}") if attempts > 5: interval = min(interval * 1.2, 30) raise TimeoutError(f"Task {task_id} timed out after {timeout}s")
pythonfrom dataclasses import dataclass, field from datetime import datetime from typing import Optional @dataclass class TrackedTask: task_id: str endpoint: str prompt: str status: str = "submitted" created_at: float = field(default_factory=time.time) result_url: Optional[str] = None error_msg: Optional[str] = None class BatchTracker: def __init__(self): self.tasks: dict[str, TrackedTask] = {} def add(self, task_id, endpoint, prompt): self.tasks[task_id] = TrackedTask(task_id=task_id, endpoint=endpoint, prompt=prompt) def update_all(self): active = [t for t in self.tasks.values() if t.status in ("submitted", "processing")] for task in active: try: r = requests.get( f"{BASE}{task.endpoint}/{task.task_id}", headers=get_headers(), timeout=30 ).json() data = r["data"] task.status = data["task_status"] if task.status == "succeed": task.result_url = data["task_result"]["videos"][0]["url"] elif task.status == "failed": task.error_msg = data.get("task_status_msg") except Exception as e: print(f"Error polling {task.task_id}: {e}") def print_report(self): by_status = {} for t in self.tasks.values(): by_status.setdefault(t.status, 0) by_status[t.status] += 1 active = sum(v for k, v in by_status.items() if k in ("submitted", "processing")) print(f"\n=== Batch: {len(self.tasks)} tasks, {active} active ===") for status, count in sorted(by_status.items()): print(f" {status}: {count}")
pythondef detect_stuck(tracker: BatchTracker, threshold_sec: int = 600): """Flag tasks processing longer than threshold.""" now = time.time() stuck = [] for t in tracker.tasks.values(): if t.status in ("submitted", "processing"): elapsed = now - t.created_at if elapsed > threshold_sec: stuck.append((t.task_id, int(elapsed))) if stuck: print(f"WARNING: {len(stuck)} stuck tasks:") for tid, secs in stuck: print(f" {tid}: {secs}s") return stuck
pythontracker = BatchTracker() # Submit batch for prompt in prompts: r = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={ "model_name": "kling-v2-master", "prompt": prompt, "duration": "5" }).json() tracker.add(r["data"]["task_id"], "/videos/text2video", prompt) # Monitor until all complete while any(t.status in ("submitted", "processing") for t in tracker.tasks.values()): time.sleep(15) tracker.update_all() tracker.print_report() detect_stuck(tracker)
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | fail→fail | 15,342 | 14,008 | -9% | 1 | 1 | 0% | 2,783 | 4,002 | +44% | 0 | 0 | — |
case-01 | fail→fail | 17,073 | 19,182 | +12% | 1 | 1 | 0% | 3,284 | 4,643 | +41% | 0 | 0 | — |
case-02 | fail→fail | 32,624 | 21,840 | -33% | 1 | 1 | 0% | 4,354 | 6,493 | +49% | 0 | 0 | — |
case-03 | pass→pass | 19,684 | 14,157 | -28% | 1 | 1 | 0% | 2,658 | 3,249 | +22% | 0 | 0 | — |
case-04 | pass→pass | 12,259 | 8,655 | -29% | 1 | 1 | 0% | 1,283 | 2,123 | +65% | 0 | 0 | — |
case-05 | pass→pass | 8,703 | 3,975 | -54% | 1 | 1 | 0% | 1,565 | 2,216 | +42% | 0 | 0 | — |
case-07 | pass→pass | 8,010 | 4,273 | -47% | 1 | 1 | 0% | 1,618 | 2,281 | +41% | 0 | 0 | — |
case-08 | fail→pass | 15,853 | 5,796 | -63% | 1 | 1 | 0% | 1,918 | 2,552 | +33% | 0 | 0 | — |
case-09 | pass→pass | 22,845 | 10,613 | -54% | 1 | 1 | 0% | 2,551 | 3,516 | +38% | 0 | 0 | — |
case-10 | pass→pass | 13,321 | 3,469 | -74% | 1 | 1 | 0% | 1,487 | 2,145 | +44% | 0 | 0 | — |
case-11 | pass→pass | 12,921 | 11,513 | -11% | 1 | 1 | 0% | 2,145 | 3,449 | +61% | 0 | 0 | — |
case-12 | fail→pass | 15,471 | 12,318 | -20% | 1 | 1 | 0% | 1,751 | 2,758 | +58% | 0 | 0 | — |
case-13 | pass→pass | 17,724 | 10,045 | -43% | 1 | 1 | 0% | 1,849 | 2,448 | +32% | 0 | 0 | — |
case-14 | pass→pass | 9,815 | 8,429 | -14% | 1 | 1 | 0% | 1,523 | 2,125 | +40% | 0 | 0 | — |
case-15 | fail→pass | 15,804 | 11,773 | -26% | 1 | 1 | 0% | 1,919 | 2,734 | +42% | 0 | 0 | — |
case-16 | fail→pass | 18,903 | 8,316 | -56% | 1 | 1 | 0% | 1,938 | 2,075 | +7% | 0 | 0 | — |
case-17 | fail→pass | 15,193 | 9,965 | -34% | 1 | 1 | 0% | 1,880 | 2,454 | +31% | 0 | 0 | — |
case-18 | pass→pass | 14,664 | 4,122 | -72% | 1 | 1 | 0% | 1,698 | 2,297 | +35% | 0 | 0 | — |
case-19 | pass→pass | 11,401 | 2,856 | -75% | 1 | 1 | 0% | 867 | 2,038 | +135% | 0 | 0 | — |
case-20 | pass→pass | 11,046 | 13,921 | +26% | 1 | 1 | 0% | 1,830 | 3,161 | +73% | 0 | 0 | — |
case-21 | pass→pass | 11,438 | 7,947 | -31% | 1 | 1 | 0% | 1,761 | 1,981 | +12% | 0 | 0 | — |
case-22 | pass→pass | 19,463 | 16,384 | -16% | 1 | 1 | 0% | 2,684 | 3,920 | +46% | 0 | 0 | — |
case-23 | pass→fail | 15,197 | 17,824 | +17% | 1 | 1 | 0% | 2,637 | 4,087 | +55% | 0 | 0 | — |
case-24 | pass→pass | 31,351 | 13,953 | -55% | 1 | 1 | 0% | 1,960 | 3,045 | +55% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +17 percentage points is the difference between those two pass rates over the 24 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.