Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize Kling AI for speed, quality, and cost efficiency. Use when improving generation times or finding optimal settings. Trigger with phrases like 'klingai performance', 'kling ai optimize', 'faster klingai', 'klingai quality settings'.
.claude/skills/jeremylongshore-klingai-performance-tuning/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -20% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 5% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 36% | 0% |
| case-09 | ✗→✓ | ▲ Improved | -23% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 79% | 0% |
Optimize video generation for your use case by choosing the right model, mode, and parameters. Covers benchmarking, speed vs. quality trade-offs, connection pooling, and caching strategies.
| Config | ~Gen Time | Quality | Credits (5s) | Best For | |--------|-----------|---------|-------------|----------| | v2.5-turbo + standard | 30-60s | Good | 10 | Drafts, iteration | | v2-master + standard | 60-90s | High | 10 | Production previews | | v2.6 + standard | 60-120s | Highest | 10 | Quality-sensitive | | v2.6 + professional | 120-300s | Highest+ | 35 | Final output | | v2.6 + prof + audio | 180-400s | Highest+ | 200 | Full production |
pythonimport time, requests, json def benchmark_model(prompt: str, model: str, mode: str = "standard", runs: int = 3) -> dict: """Benchmark generation time for a model/mode combination.""" times = [] for i in range(runs): start = time.monotonic() # Submit r = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={ "model_name": model, "prompt": prompt, "duration": "5", "mode": mode, }).json() task_id = r["data"]["task_id"] # Poll while True: time.sleep(10) result = requests.get( f"{BASE}/videos/text2video/{task_id}", headers=get_headers() ).json() if result["data"]["task_status"] in ("succeed", "failed"): break elapsed = time.monotonic() - start times.append(elapsed) print(f" Run {i+1}/{runs}: {elapsed:.1f}s ({result['data']['task_status']})") return { "model": model, "mode": mode, "avg_sec": round(sum(times) / len(times), 1), "min_sec": round(min(times), 1), "max_sec": round(max(times), 1), "runs": runs, } # Compare models prompt = "A waterfall in a tropical forest, cinematic" for model in ["kling-v2-5-turbo", "kling-v2-master", "kling-v2-6"]: result = benchmark_model(prompt, model, runs=2) print(f"{model}: avg={result['avg_sec']}s, min={result['min_sec']}s")
pythonimport requests # Without pooling: new TCP connection per request (slow) # With pooling: reuse connections (fast) session = requests.Session() adapter = requests.adapters.HTTPAdapter( pool_connections=5, # number of connection pools pool_maxsize=10, # max connections per pool max_retries=3, # auto-retry on connection errors ) session.mount("https://", adapter) # Use session instead of requests directly response = session.post(f"{BASE}/videos/text2video", headers=get_headers(), json=body)
Prompts that generate faster:
| Technique | Why It Helps | |-----------|-------------| | Clear single subject | Less complexity to resolve | | Specify camera angle | Reduces ambiguity | | Avoid conflicting styles | "realistic anime" confuses the model | | Keep under 200 words | Shorter prompts process faster | | Use negative prompts | Removes processing of unwanted elements |
python# Slow prompt (vague, conflicting) slow = "A scene with many things happening, realistic but also artistic" # Fast prompt (specific, clear) fast = "A single red fox walking through snow, side view, natural lighting, 4K"
pythonimport hashlib class PromptCache: """Cache results to avoid regenerating identical videos.""" def __init__(self): self._cache = {} def _key(self, prompt: str, model: str, duration: int, mode: str) -> str: raw = f"{prompt}|{model}|{duration}|{mode}" return hashlib.sha256(raw.encode()).hexdigest()[:16] def get(self, prompt, model, duration, mode): key = self._key(prompt, model, duration, mode) return self._cache.get(key) def set(self, prompt, model, duration, mode, video_url): key = self._key(prompt, model, duration, mode) self._cache[key] = { "url": video_url, "cached_at": time.time(), } cache = PromptCache() def generate_with_cache(prompt, model="kling-v2-master", duration=5, mode="standard"): cached = cache.get(prompt, model, duration, mode) if cached: print(f"Cache hit: {cached['url']}") return cached["url"] # Generate result = client.text_to_video(prompt, model=model, duration=duration, mode=mode) url = result["videos"][0]["url"] cache.set(prompt, model, duration, mode, url) return url
kling-v2-5-turbo for iteration, v2-6 for finalstandard mode until final renderrequests.Session()callback_url instead of polling| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 54,621 | 27,292 | -50% | 1 | 1 | 0% | 8,245 | 6,630 | -20% | 0 | 0 | — |
case-08 | pass→pass | 15,957 | 6,345 | -60% | 1 | 1 | 0% | 2,319 | 2,469 | +6% | 0 | 0 | — |
case-18 | pass→pass | 49,732 | 19,544 | -61% | 1 | 1 | 0% | 2,822 | 3,861 | +37% | 0 | 0 | — |
case-02 | fail→pass | 31,428 | 25,229 | -20% | 1 | 1 | 0% | 5,147 | 5,418 | +5% | 0 | 0 | — |
case-03 | fail→fail | 23,869 | 21,197 | -11% | 1 | 1 | 0% | 2,887 | 4,554 | +58% | 0 | 0 | — |
case-04 | fail→pass | 12,495 | 13,440 | +8% | 1 | 1 | 0% | 2,349 | 3,184 | +36% | 0 | 0 | — |
case-05 | pass→pass | 14,729 | 9,940 | -33% | 1 | 1 | 0% | 1,865 | 2,439 | +31% | 0 | 0 | — |
case-06 | fail→fail | 30,087 | 20,216 | -33% | 1 | 1 | 0% | 2,872 | 4,583 | +60% | 0 | 0 | — |
case-07 | fail→fail | 21,162 | 19,114 | -10% | 1 | 1 | 0% | 2,793 | 4,126 | +48% | 0 | 0 | — |
case-09 | fail→pass | 22,340 | 11,881 | -47% | 1 | 1 | 0% | 3,097 | 2,384 | -23% | 0 | 0 | — |
case-10 | pass→pass | 10,097 | 8,114 | -20% | 1 | 1 | 0% | 841 | 2,099 | +150% | 0 | 0 | — |
case-11 | fail→fail | 20,295 | 21,737 | +7% | 1 | 1 | 0% | 2,434 | 5,052 | +108% | 0 | 0 | — |
case-12 | pass→pass | 23,998 | 11,598 | -52% | 1 | 1 | 0% | 3,392 | 3,914 | +15% | 0 | 0 | — |
case-13 | fail→pass | 23,179 | 27,910 | +20% | 1 | 1 | 0% | 2,744 | 4,903 | +79% | 0 | 0 | — |
case-14 | fail→pass | 8,907 | 10,054 | +13% | 1 | 1 | 0% | 1,607 | 2,430 | +51% | 0 | 0 | — |
case-15 | fail→pass | 17,927 | 17,799 | -1% | 1 | 1 | 0% | 2,890 | 3,898 | +35% | 0 | 0 | — |
case-16 | fail→pass | 14,116 | 2,716 | -81% | 1 | 1 | 0% | 1,608 | 1,880 | +17% | 0 | 0 | — |
case-17 | pass→pass | 16,113 | 16,408 | +2% | 1 | 1 | 0% | 2,677 | 4,233 | +58% | 0 | 0 | — |
case-19 | fail→pass | 17,365 | 9,472 | -45% | 1 | 1 | 0% | 1,922 | 2,229 | +16% | 0 | 0 | — |
case-20 | pass→pass | 18,848 | 16,064 | -15% | 1 | 1 | 0% | 2,647 | 4,173 | +58% | 0 | 0 | — |
case-21 | pass→pass | 15,448 | 22,636 | +47% | 1 | 1 | 0% | 2,993 | 4,255 | +42% | 0 | 0 | — |
case-22 | pass→pass | 23,198 | 25,579 | +10% | 1 | 1 | 0% | 2,544 | 4,457 | +75% | 0 | 0 | — |
case-23 | pass→pass | 14,690 | 2,796 | -81% | 1 | 1 | 0% | 1,679 | 2,015 | +20% | 0 | 0 | — |
case-24 | fail→pass | 18,808 | 9,870 | -48% | 1 | 1 | 0% | 2,046 | 2,464 | +20% | 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 +42 percentage points is the difference between those two pass rates over the 24 comparable cases.
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.