Application Process
To use the API, you need to first apply for the corresponding service on the Kling Motion Generation API page. After entering the page, click the “Acquire” button, as shown in the image:
If you are not logged in or registered, you will be automatically redirected to the login page inviting you to register and log in. After logging in or registering, you will be automatically returned to the current page.
Upon the first application, there will be a free quota provided, allowing you to use the API for free.
Basic Usage
First, understand the basic usage method, which involves inputting the promptprompt, reference image image_url, and reference video link video_url to obtain the processed result. We also need to input the model mode, which currently mainly includes std and pro models, as detailed below:

accept: the format of the response result you want to receive, filled in asapplication/json, which means JSON format.authorization: the key to call the API, which can be selected directly after application.
image_url: the reference image, which serves as the basis for the characters, backgrounds, and other elements in the generated video.video_url: the link to obtain the reference video. The actions of the characters in the generated video will be consistent with the reference video.mode: the mode for generating the video, mainly including standard modestdand high-speed modepro.keep_original_sound: an option to choose whether to keep the original sound of the video, with enumerated values: yes, no.character_orientation: the orientation of the characters in the generated video, which can be chosen to be consistent with the image or the video, with enumerated values: image, video.prompt: the prompt.callback_url: the URL to receive the callback result.

success: the status of the video generation task at this time.task_id: the ID of the video generation task at this time.video_id: the video ID of the video generation task at this time.video_url: the video link of the video generation task at this time.duration: the duration of the video generation task at this time.state: the status of the video generation task at this time.
data result.
Additionally, if you want to generate the corresponding integration code, you can directly copy the generated code, for example, the CURL code is as follows:
Asynchronous Callback
Since the time taken by the Kling Motion Generation API to generate is relatively long, approximately 1-2 minutes, if the API does not respond for a long time, the HTTP request will keep the connection open, leading to additional system resource consumption. Therefore, this API also provides support for asynchronous callbacks. The overall process is: when the client initiates a request, an additionalcallback_url field is specified. After the client initiates the API request, the API will immediately return a result containing a task_id field, representing the current task ID. When the task is completed, the result of the generated video will be sent to the client-specified callback_url in the form of a POST JSON, which also includes the task_id field, allowing the task result to be associated by ID.
Let’s understand how to operate specifically through an example.
First, the Webhook callback is a service that can receive HTTP requests, and developers should replace it with the URL of their own HTTP server. For demonstration purposes, we will use a public Webhook sample site https://webhook.site/, where you can open the site to obtain a Webhook URL, as shown in the image:
Copy this URL to use it as a Webhook, the example here is https://webhook.site/624b2c78-6dbd-4618-9d2b-b32eade6d8c3.
Next, we can set the field callback_url to the above Webhook URL, while filling in the corresponding parameters, the specific content is as shown in the image:

https://webhook.site/624b2c78-6dbd-4618-9d2b-b32eade6d8c3, as shown in the image:
The content is as follows:
task_id field, and the other fields are similar to the above text, which allows for task association through this field.
Error Handling
When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:400 token_mismatched: Bad request, possibly due to missing or invalid parameters.400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.401 invalid_token: Unauthorized, invalid or missing authorization token.429 too_many_requests: Too many requests, you have exceeded the rate limit.500 api_error: Internal server error, something went wrong on the server.

