Skip to content

Image Expansion

POST https://www.kkiai.com/kling/v1/images/editing/expand

Request Parameters

Authorization

Add the Authorization parameter to the Header. Its value is the Token concatenated after Bearer.

Example: Authorization: Bearer ********************

Header Parameters

Parameter NameTypeRequiredDescriptionExample
Content-TypestringOptionalapplication/json
AuthorizationstringOptionalBearer {{YOUR_API_KEY}}

Body Parameters (application/json)

Parameter NameTypeRequiredDescription
imagestringRequiredReference image. Supports Base64 encoded image or image URL (must be accessible)
up_expansion_rationumberRequiredUpward expansion range; calculated as a multiple of the original image height. Value range: [0,2]. The total area of the new image must not exceed 3 times the original image. For example, if the original image height is 20 and the current parameter value is 0.1, then: the distance from the top edge of the original image to the top edge of the new image is 20 x 0.1 = 2, and the area within is the expansion range
down_expansion_rationumberRequiredDownward expansion range; calculated as a multiple of the original image height. Value range: [0,2]. The total area of the new image must not exceed 3 times the original image. For example, if the original image height is 20 and the current parameter value is 0.2, then: the distance from the bottom edge of the original image to the bottom edge of the new image is 20 x 0.2 = 4, and the area within is the expansion range
left_expansion_rationumberRequiredLeftward expansion range; calculated as a multiple of the original image width. Value range: [0,2]. The total area of the new image must not exceed 3 times the original image. For example, if the original image width is 30 and the current parameter value is 0.3, then: the distance from the left edge of the original image to the left edge of the new image is 30 x 0.3 = 9, and the area within is the expansion range
right_expansion_rationumberRequiredRightward expansion range; calculated as a multiple of the original image width. Value range: [0,2]. The total area of the new image must not exceed 3 times the original image. For example, if the original image width is 30 and the current parameter value is 0.4, then: the distance from the right edge of the original image to the right edge of the new image is 30 x 0.4 = 12, and the area within is the expansion range
promptstringOptionalPositive text prompt. Must not exceed 2500 characters
nintegerRequiredNumber of images to generate. Value range: [1,9]
callback_urlstringOptional
external_task_idstringOptional

Request Example

json
{
    "image": "https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg",
    "up_expansion_ratio": 0.1,
    "down_expansion_ratio": 0.1,
    "left_expansion_ratio": 0.1,
    "right_expansion_ratio": 0.1,
    "prompt": "Focus on the center.",
    "n": 1,
    "callback_url": "",
    "external_task_id": ""
}

cURL Example

bash
curl --location --request POST 'https://www.kkiai.com/kling/v1/images/editing/expand' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "image": "https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg",
    "up_expansion_ratio": 0.1,
    "down_expansion_ratio": 0.1,
    "left_expansion_ratio": 0.1,
    "right_expansion_ratio": 0.1,
    "prompt": "Focus on the center.",
    "n": 1,
    "callback_url": "",
    "external_task_id": ""
}'

Response

🟢 200 Success

Response Example

json
{}