AGTCloud API Docs
GuidesAPI ReferenceIntegrations and resourcesUpdate and help
Video generationKling

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.

POST/kling/image-to-video/kling-4.0

Generate 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
AuthorizationBearer <token>

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.

ItemRequirement
Image sourceurl is required; URL or Base64 is supported
Format and sizeJPG, JPEG, PNG; up to 30MB per image
DimensionsWidth and height at least 300px; aspect ratio from 2:5 to 5:2
Image countUp to 10 per task
Asset reference IDid 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 errorWhat to check
HTTP 401, Invalid tokenCheck Bearer authentication and whether the API Key belongs to the requested site
HTTP 400, contents cannot be emptyProvide a nonempty contents array
HTTP 400, contents must contain at least one of first_frame, middle_frame, last_frameProvide at least one keyframe image; a prompt alone is insufficient
HTTP 400, must have a non-blank urlSupply a nonempty url for the relevant keyframe
HTTP 400, contents[0].type ... is invalidCheck the asset at the indicated index and use a supported keyframe or prompt type
HTTP 400, invalid_request or invalid JSON request bodyCheck 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.