Skip to main content
This article will introduce the integration instructions for the Kling Motion Generation API, which can generate official Kling videos by inputting custom parameters.

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 prompt prompt, 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:

Here we can see that we have set the Request Headers, including:
  • accept: the format of the response result you want to receive, filled in as application/json, which means JSON format.
  • authorization: the key to call the API, which can be selected directly after application.
Additionally, we have set the Request Body, including:
  • 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 mode std and high-speed mode pro.
  • 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.
After selection, you can see that the corresponding code is generated on the right side, as shown in the image:

Click the “Try” button to conduct a test, as shown in the image above, and we obtained the following result:
{
  "success": true,
  "video_id": "842578800134742051",
  "video_url": "https://v4-fdl.kechuangai.com/ksc2/yGPGHvUVDQEzDCs6tC0rYIbd_JwWNFaF8BEYAlw_xVcWX72xFuIUVqB_Hp5Sa7YEijI-yXqfKI92WW7bmyeCtpMjSOImlOFpQCmMUa-9iojt_ifXJnex_tvNkA0ZlJmuJLpeOfvX3j8d9oeeWgLeU3ftzBjQq1g9OC9FU92OfjRQLUTSzfWRzkhzirV32BT-BwfxgqJKsUD-WHxjqCJmOw.mp4?cacheKey=ChtzZWN1cml0eS5rbGluZy5tZXRhX2VuY3J5cHQSsAHtyCrKxB23NXn5ddMedV5Mw4pp_kOk_TRbCVA-wO9LJZuga8_KxXCzhw6bU3hS1V5PpNoSTxSkm_E80i5U1PkJ5d444cjPvoIq2VboPqCip2QbsoiVMu6CuGP7tB7fStLbezBNA4lQtHeSVPxWTE7Hy0wbJ33tKlf-X_-1ad3u0cyHfT_8EroD4iYZ1ZVasuYxAKjcdmbbVZ7NlDK9rqyI5euyz-70-M-QM5Lk6l88SRoSS2Y9drB8Z4ednHxTIh7XZcnaIiB5Xf4Mv8Rc51nUyIC5lKp02LP7oViCg6OaAhR4ynNJkCgFMAE&x-kcdn-pid=112757&pkey=AAX8ukavvkZsIz-IUg2pTvMOAV7LVItIdg_5TUYhGA1YINT8x-SR7rXY7BWLKqspLTYIjK7C0SjbXtX25Lm4_sx2V229AIyfVzjrlQQ7IjPsxvAv9cTG72YN0TPSjVowBZQ",
  "duration": "5.066",
  "state": "succeed",
  "task_id": "363c7a84-e880-472e-a4d4-098e50cfc292"
}
The returned result contains multiple fields, described as follows:
  • 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.
We can see that we have obtained satisfactory video information, and we only need to access the generated Kling video using the video link address in the 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:
curl -X POST 'https://api.acedata.cloud/kling/motion' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "image_url": "https://sourceyoya.wenge.com/2025/06/03/683e9f76e4b0684509ab1aca.jpg",
  "video_url": "https://cdn.acedata.cloud/odwfm5.mp4",
  "prompt": "Make the picture come alive",
  "mode": "std",
  "character_orientation": "image"
}'

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 additional callback_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:

Clicking run, you will find that a result is immediately obtained, as follows:
{
  "task_id": "20068983-0cc9-4c6a-aeb6-9c6a3c668be0"
}
After a moment, we can observe the generated video results at https://webhook.site/624b2c78-6dbd-4618-9d2b-b32eade6d8c3, as shown in the image: The content is as follows:
{
    "success": true,
    "video_id": "030bb06d-98d4-4044-9042-0aa0822e8c8c",
    "video_url": "https://cdn.klingai.com/bs2/upload-kling-api/7822108635/text2video/CjJzzGfBfqcAAAAAAKdVMQ-0_raw_video_1.mp4",
    "duration": "5.1",
    "state": "succeed",
    "task_id": "20068983-0cc9-4c6a-aeb6-9c6a3c668be0"
}
It can be seen that the result contains a 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.

Error Response Example

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

Conclusion

Through this document, you have learned how to use the Kling Motion Generation API to implement the official motion control features of Kling. We hope this document helps you better integrate and use this API. If you have any questions, please feel free to contact our technical support team.