Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Handle Kling AI API rate limits with backoff and queuing strategies. Use when hitting 429 errors or planning high-volume workflows. Trigger with phrases like 'klingai rate limit', 'kling ai 429', 'klingai throttle', 'kling api limits'.
.claude/skills/jeremylongshore-klingai-rate-limits/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | -10% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-13 | ✗→✓ | ▲ Improved | -15% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 0% | 0% |
| case-17 | ✗→✓ | ▲ Improved | -13% | 0% |
Kling AI enforces rate limits per API key. When exceeded, the API returns 429 Too Many Requests. This skill covers detection, backoff strategies, request queuing, and concurrent job management.
| Tier | Concurrent Tasks | Requests/Min | Notes | |------|------------------|-------------|-------| | Free | 1 | 10 | 66 daily credits cap | | Standard | 3 | 30 | Per API key | | Pro | 5 | 60 | Per API key | | Enterprise | 10+ | Custom | Contact sales |
pythonimport time, random, requests def exponential_backoff(attempt: int, base: float = 1.0, max_wait: float = 60.0) -> float: """Calculate wait time with jitter to avoid thundering herd.""" wait = min(base * (2 ** attempt), max_wait) jitter = random.uniform(0, wait * 0.5) return wait + jitter def request_with_retry(method, url, headers, json=None, max_retries=5): for attempt in range(max_retries + 1): response = method(url, headers=headers, json=json, timeout=30) if response.status_code == 429: if attempt == max_retries: raise RuntimeError("Rate limit: max retries exceeded") wait = exponential_backoff(attempt) print(f"429 rate limited. Waiting {wait:.1f}s (attempt {attempt + 1})") time.sleep(wait) continue if response.status_code >= 500: if attempt == max_retries: response.raise_for_status() time.sleep(exponential_backoff(attempt, base=2.0)) continue response.raise_for_status() return response raise RuntimeError("Unreachable")
pythonimport asyncio class TaskLimiter: """Limit concurrent Kling AI tasks to stay within API tier.""" def __init__(self, max_concurrent: int = 3): self._semaphore = asyncio.Semaphore(max_concurrent) self._active = 0 async def submit(self, coro): async with self._semaphore: self._active += 1 try: return await coro finally: self._active -= 1 @property def active_count(self) -> int: return self._active # Usage limiter = TaskLimiter(max_concurrent=3) tasks = [limiter.submit(generate_video(p)) for p in prompts] results = await asyncio.gather(*tasks, return_exceptions=True)
pythonclass RateLimitMonitor: """Track API call frequency and warn before hitting limits.""" def __init__(self, max_per_minute: int = 30): self.max_per_minute = max_per_minute self._calls = [] def record_call(self): now = time.time() self._calls = [t for t in self._calls if now - t < 60] self._calls.append(now) @property def usage_pct(self) -> float: now = time.time() recent = sum(1 for t in self._calls if now - t < 60) return (recent / self.max_per_minute) * 100 def wait_if_needed(self): if self.usage_pct > 80 and self._calls: wait = 60 - (time.time() - self._calls[0]) if wait > 0: print(f"Throttling: waiting {wait:.1f}s ({self.usage_pct:.0f}% of limit)") time.sleep(wait)
pythonfrom collections import deque import threading class RequestQueue: """FIFO queue with rate-limit-aware dispatch.""" def __init__(self, client, max_per_minute: int = 30): self.client = client self.interval = 60.0 / max_per_minute self._queue = deque() def enqueue(self, endpoint: str, body: dict, callback=None): self._queue.append((endpoint, body, callback)) def process_all(self): while self._queue: endpoint, body, callback = self._queue.popleft() try: result = self.client._post(endpoint, body) if callback: callback(result, error=None) except Exception as e: if callback: callback(None, error=e) time.sleep(self.interval)
| Scenario | HTTP Code | Action | |----------|-----------|--------| | Soft rate limit | 429 + Retry-After | Wait specified seconds | | Hard rate limit | 429 no header | Backoff from 1s, double each attempt | | Concurrent limit hit | 429 or task rejection | Wait for active tasks to complete | | Burst detection | Multiple 429s | Aggressive backoff (30-60s) |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 19,024 | 20,343 | +7% | 1 | 1 | 0% | 3,953 | 4,680 | +18% | 0 | 0 | — |
case-02 | fail→fail | 40,312 | 30,833 | -24% | 1 | 1 | 0% | 3,357 | 5,883 | +75% | 0 | 0 | — |
case-03 | fail→fail | 21,930 | 22,617 | +3% | 1 | 1 | 0% | 3,330 | 5,190 | +56% | 0 | 0 | — |
case-04 | pass→pass | 14,851 | 13,987 | -6% | 1 | 1 | 0% | 1,970 | 4,221 | +114% | 0 | 0 | — |
case-05 | pass→pass | 26,803 | 15,969 | -40% | 1 | 1 | 0% | 2,893 | 4,371 | +51% | 0 | 0 | — |
case-06 | pass→pass | 16,519 | 8,282 | -50% | 1 | 1 | 0% | 2,237 | 3,020 | +35% | 0 | 0 | — |
case-07 | fail→pass | 19,094 | 7,109 | -63% | 1 | 1 | 0% | 1,861 | 1,672 | -10% | 0 | 0 | — |
case-08 | fail→pass | 8,623 | 2,878 | -67% | 1 | 1 | 0% | 1,427 | 1,772 | +24% | 0 | 0 | — |
case-09 | pass→pass | 17,411 | 8,107 | -53% | 1 | 1 | 0% | 2,061 | 1,736 | -16% | 0 | 0 | — |
case-10 | pass→pass | 11,195 | 3,284 | -71% | 1 | 1 | 0% | 1,662 | 1,863 | +12% | 0 | 0 | — |
case-11 | pass→pass | 20,736 | 17,561 | -15% | 1 | 1 | 0% | 2,903 | 3,960 | +36% | 0 | 0 | — |
case-12 | pass→pass | 21,218 | 23,692 | +12% | 1 | 1 | 0% | 4,068 | 6,207 | +53% | 0 | 0 | — |
case-13 | fail→pass | 13,022 | 9,353 | -28% | 1 | 1 | 0% | 2,486 | 2,101 | -15% | 0 | 0 | — |
case-14 | pass→pass | 12,337 | 18,085 | +47% | 1 | 1 | 0% | 2,321 | 3,387 | +46% | 0 | 0 | — |
case-15 | pass→pass | 16,403 | 5,027 | -69% | 1 | 1 | 0% | 1,918 | 1,875 | -2% | 0 | 0 | — |
case-16 | fail→pass | 12,505 | 7,297 | -42% | 1 | 1 | 0% | 1,672 | 1,665 | -0% | 0 | 0 | — |
case-17 | fail→pass | 21,346 | 10,057 | -53% | 1 | 1 | 0% | 2,391 | 2,091 | -13% | 0 | 0 | — |
case-18 | pass→pass | 18,298 | 12,349 | -33% | 1 | 1 | 0% | 2,084 | 3,194 | +53% | 0 | 0 | — |
case-19 | pass→pass | 11,268 | 6,593 | -41% | 1 | 1 | 0% | 1,014 | 1,557 | +54% | 0 | 0 | — |
case-20 | pass→pass | 7,857 | 9,001 | +15% | 1 | 1 | 0% | 1,160 | 2,009 | +73% | 0 | 0 | — |
case-21 | pass→pass | 20,969 | 11,679 | -44% | 1 | 1 | 0% | 3,026 | 2,769 | -8% | 0 | 0 | — |
case-22 | fail→pass | 19,787 | 8,383 | -58% | 1 | 1 | 0% | 2,003 | 1,773 | -11% | 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. 22 cases were attempted. The headline lift of +27 percentage points is the difference between those two pass rates over the 22 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.