「Kling AI」API Specification
Update Time | Update Notes |
2024.12.2 | 【Video Generation】 ●With multiple versions of the video generation model (V1, V1.5) and various plugin capabilities (e.g., camera control, start/end frame, motion brush, video extension, etc.), we have created a "Capability Map" to make it easier for everyone to visually check the availability of different versions and features. For details, please refer to the "3-0 Capability Map." |
2024.11.29 | 【Video Generation - ImageToVideo】New Feature: Motion Brush ●This feature is only supported in Standard Mode 5s and Professional Mode 5s for the V1.0 model, and is currently not available for the V1.5 model. |
2024.11.15 | 【Video Generation】Kling V1.5 Pro Model Now Open for Video Generation: Image-to-Video Functionality Enabled, Text-to-Video Unsupported ●Only supports professional mode ●Tail frame control is not supported ●All other parameters are supported 【Video Generation】 New Feature: Video Extension ● Supports extending videos generated by the V1.0 model directly, adding 4-5 seconds of video length per extension ●Includes create task, query task (single), and query task (list) interfaces 【Video Generation】Other Updates ● Added "external_task_id" field, allowing you to customize a task ID when creating a task, and query the video using this custom ID when needed |
2024.10.30 | Added the "Query Resource Package List and Remaining Quantity" interface for your convenience. See "Section VI: Account Information Query". |
2024.10.25 | To clarify the storage duration of model-generated content (images/videos): ●To ensure information security, generated images/videos will be cleared after 30 days. Please make sure to save them promptly. |
2024.10.15 | Add a sample Java code for generating the API_Token. |
2024.9.19 | Video Generation ●When creating a task, the character limit for the prompt and negative_prompt in the request parameters has been updated to: cannot exceed 2500 characters. |
2024.9.19 | Officially supporting the "AI Virtual Try-on" related API (kolors-virtual-try-on). |
I. General Information
1.API Domain
💎
https://api.klingai.com
2.API Authentication
●Step-1:Obtain AccessKey + SecretKey
●Step-2:Every time you request the API, you need to generate an API Token according to the Fixed Encryption Method, Authorization = Bearer <API Token> in Requset Header
●Encryption Method:Follow JWT(Json Web Token, RFC 7519)standard
●JWT consists of three parts:Header、Payload、Signature
●Sample code (Python):
●Sample code (Java):
3.Error Code
HTTP Status Code | Service Code | Definition of Service Code | Explaination of Service Code | Suggested Solutions |
200 | 0 | Request | - | - |
401 | 1000 | Authentication failed | Authentication failed | Check if the Authorization is correct |
401 | 1001 | Authentication failed | Authorization is empty | Fill in the correct Authorization in the Request Header |
401 | 1002 | Authentication failed | Authorization is invalid | Fill in the correct Authorization in the Request Header |
401 | 1003 | Authentication failed | Authorization is not yet valid | Check the start effective time of the token, wait for it to take effect or reissue |
401 | 1004 | Authentication failed | Authorization has expired | Check the validity period of the token and reissue it |
429 | 1100 | Account exception | Account exception | Verifying account configuration information |
429 | 1101 | Account exception | Account in arrears (postpaid scenario) | Recharge the account to ensure sufficient balance |
429 | 1102 | Account exception | Resource pack depleted or expired (prepaid scenario) | Purchase additional resource packages, or activate the post-payment service (if available) |
403 | 1103 | Account exception | Unauthorized access to requested resource, such as API/model | Verifying account permissions |
400 | 1200 | Invalid request parameters | Invalid request parameters | Check whether the request parameters are correct |
400 | 1201 | Invalid request parameters | Invalid parameters, such as incorrect key or illegal value | Refer to the specific information in the message field of the returned body and modify the request parameters |
404 | 1202 | Invalid request parameters | The requested method is invalid | Review the API documentation and use the correct request method |
404 | 1203 | Invalid request parameters | The requested resource does not exist, such as the model | Refer to the specific information in the message field of the returned body and modify the request parameters |
400 | 1300 | Trigger strategy | Trigger strategy of the platform | Check if any platform policies have been triggered |
400 | 1301 | Trigger strategy | Trigger the content security policy of the platform | Check the input content, modify it, and resend the request |
429 | 1302 | Trigger strategy | The API request is too fast, exceeding the platform's rate limit | Reduce the request frequency, try again later, or contact customer service to increase the limit |
429 | 1303 | Trigger strategy | Concurrency or QPS exceeds the prepaid resource package limit | Reduce the request frequency, try again later, or contact customer service to increase the limit |
429 | 1304 | Trigger strategy | Trigger the platform's IP whitelisting policy | Contact customer service |
500 | 5000 | Internal error | Server internal error | Try again later, or contact customer service |
503 | 5001 | Internal error | Server temporarily unavailable, usually due to maintenance | Try again later, or contact customer service |
504 | 5002 | Internal error | Server internal timeout, usually due to a backlog | Try again later, or contact customer service |