v1

latestOpenAPI 3.1.02026-07-26793302.3 KB

Request a Kling image-expansion task

Expand a source image beyond its original borders. Verify route availability before integrating.

post/kling/v1/images/editing/expand

Headers

Content-Typestring

Optional content type header.

Request body

imagestring required

Source image to expand. Accepts an image URL or raw Base64 string (no data: prefix). Supported formats: JPG, JPEG, PNG. Max 10 MB, minimum 300×300 px, aspect ratio between 1:2.5 and 2.5:1.

up_expansion_rationumber required

Upward expansion as a multiple of the original image height. Range: 0–2. The resulting image area must not exceed 3× the original.

right_expansion_rationumber required

Rightward expansion as a multiple of the original image width. Range: 0–2. The resulting image area must not exceed 3× the original.

left_expansion_rationumber required

Leftward expansion as a multiple of the original image width. Range: 0–2. The resulting image area must not exceed 3× the original.

promptstring

Optional text prompt to guide the expanded area content. Max 2500 characters.

bottom_expansion_rationumber required

Downward expansion as a multiple of the original image height. Range: 0–2. The resulting image area must not exceed 3× the original.

nstring

Number of expanded images to generate.

callback_urlstring

Webhook URL for task status notifications. The server sends a callback when the task status changes.

external_task_idstring

Optional user-defined task ID for your own tracking. Does not replace the system-generated task ID. Must be unique per account.

Response

Task accepted when the route is available.

codeinteger required

Error code; specifically define the error code

messagestring required

error message

request_idstring

Request ID, system-generated, for tracking requests, troubleshooting issues