| name | klingai-install-auth |
| description | Set up Kling AI API authentication with JWT tokens. Use when starting a new Kling AI
integration or troubleshooting auth issues. Trigger with phrases like 'kling ai setup',
'klingai api key', 'kling ai authentication', 'configure klingai'.
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.18.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kling-ai","api","authentication"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Kling AI Install & Auth
Overview
Kling AI uses JWT (JSON Web Token) authentication. You generate a token from your Access Key (AK) and Secret Key (SK), then pass it as a Bearer token in every request. Tokens expire after 30 minutes.
Base URL: https://api.klingai.com/v1
Prerequisites
- Kling AI account at klingai.com
- API access enabled (self-service, no waitlist)
- Python 3.8+ with
PyJWT or Node.js 18+
Step 1 — Get Credentials
- Sign in at app.klingai.com/global/dev
- Navigate to API Keys in the developer console
- Click Create API Key to generate an Access Key + Secret Key pair
- Store both values securely — the Secret Key is shown only once
KLING_ACCESS_KEY="ak_your_access_key_here"
KLING_SECRET_KEY="sk_your_secret_key_here"
Step 2 — Generate JWT Token
Python
import jwt
import time
import os
def generate_kling_token():
"""Generate a JWT token for Kling AI API authentication."""
ak = os.environ["KLING_ACCESS_KEY"]
sk = os.environ["KLING_SECRET_KEY"]
headers = {"alg": "HS256", "typ": "JWT"}
payload = {
"iss": ak,
"exp": int(time.time()) + 1800,
"nbf": int(time.time()) - 5,
}
return jwt.encode(payload, sk, algorithm="HS256", headers=headers)
token = generate_kling_token()