Image-to-video
Generate Kling 4.0 video from a first frame, first and last frames, or multiple keyframes.
Combine prompts and keyframes in contents, with up to 10 images per task. This endpoint does not provide aspect_ratio; use reference images with the intended aspect ratio.
/kling/image-to-video/kling-4.0Generate video from a first frame, first and last frames, or multiple keyframes, with up to 10 images per task. The reference image determines the aspect ratio; aspect_ratio is not provided.
Authorization
bearerAuth Use a platform API Key: Authorization: Bearer your-api-key.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
Image and reference rules
contents supports first_frame (first frame), middle_frame (middle frame), and last_frame (last frame). The prompt item type: "prompt" is optional. The request examples cover a first frame, first and last frames, and multiple keyframes.
| Item | Requirement |
|---|---|
| Image source | url is required; URL or Base64 is supported |
| Format and size | JPG, JPEG, PNG; up to 30MB per image |
| Dimensions | Width and height at least 300px; aspect ratio from 2:5 to 5:2 |
| Image count | Up to 10 per task |
| Asset reference ID | id is optional; supplied values must be unique within the task |
To refer to an image in the prompt, assign an id, for example "id": "first" corresponds to @first. id is a reference within this request, not the returned generation task ID.
Common errors and troubleshooting
| Response or error | What to check |
|---|---|
HTTP 401, Invalid token | Check Bearer authentication and whether the API Key belongs to the requested site |
HTTP 400, contents cannot be empty | Provide a nonempty contents array |
HTTP 400, contents must contain at least one of first_frame, middle_frame, last_frame | Provide at least one keyframe image; a prompt alone is insufficient |
HTTP 400, must have a non-blank url | Supply a nonempty url for the relevant keyframe |
HTTP 400, contents[0].type ... is invalid | Check the asset at the indicated index and use a supported keyframe or prompt type |
HTTP 400, invalid_request or invalid JSON request body | Check JSON syntax and field types; contents must be an array, not a string |
HTTP 400 may return code/message/data or an error object. fail_to_fetch_task does not necessarily mean retrieval failed; read the asset validation cause in message. It may be a JSON string, not a parsed object. Keep the request ID, but do not share your API Key.