Authentication
Kling AI uses JWT-based Bearer token authentication.
Getting an API Key
- Sign up at klingai.com
- Navigate to your account settings to obtain your Access Key and Secret Key
- Generate JWT tokens using HS256 with your Access Key as the
issclaim
Usage
1 2 3 4 | |
Environment Variables
For integration tests, set the KLINGAI_API_KEY environment variable:
1 | |
JWT Token Generation
Kling AI requires JWT tokens with a 30-minute expiry. The token payload should include:
| Claim | Description |
|---|---|
iss |
Your Access Key |
exp |
Expiration time (Unix timestamp, max 30 minutes from now) |
nbf |
Not-before time (Unix timestamp, typically current time - 5 seconds) |
Sign the token using HS256 with your Secret Key.