klingai-known-pitfalls

Featured

Avoid common mistakes when using Kling AI API. Use when troubleshooting or learning best practices. Trigger with phrases like 'klingai pitfalls', 'kling ai mistakes', 'klingai gotchas', 'klingai best practices'.

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Kling AI Known Pitfalls ## Overview Documented mistakes, gotchas, and anti-patterns from real Kling AI integrations. Each pitfall includes the symptom, root cause, and tested fix. ## Pitfall 1: Duration as Integer **Symptom:** `400 Bad Request` on valid-looking requests. ```python # WRONG -- duration as integer {"duration": 5} # CORRECT -- duration as string {"duration": "5"} ``` The API requires `duration` as a string `"5"` or `"10"`, not an integer. ## Pitfall 2: JWT Without Explicit Headers **Symptom:** `401 Unauthorized` even with correct AK/SK. ```python # WRONG -- missing headers parameter token = jwt.encode(payload, sk, algorithm="HS256") # CORRECT -- explicit JWT headers token = jwt.encode(payload, sk, algorithm="HS256", headers={"alg": "HS256", "typ": "JWT"}) ``` Some JWT libraries don't include `typ: "JWT"` by default. Kling requires it. ## Pitfall 3: Token Generated Once at Import Time **Symptom:** Works for 30 minutes, then all requests fail with `401`. ```python # WRONG -- token generated once TOKEN = generate_token() # at module import headers = {"Authorization": f"Bearer {TOKEN}"} # CORRECT -- generate fresh token per request (or auto-refresh) def get_headers(): return {"Authorization": f"Bearer {generate_token()}"} ``` JWT tokens expire after 30 minutes. Always implement auto-refresh. ## Pitfall 4: Polling Without Timeout **Symptom:** Script hangs forever on a failed task. ```python # WRONG -- infinite loop while T...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category