Skip to main content
POST
/
kling
/
v1
/
images
/
editing
/
expand
cURL
curl https://api.cometapi.com/kling/v1/images/editing/expand \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "image": "https://your-image-host/source.jpg",
  "up_expansion_ratio": 0.1,
  "down_expansion_ratio": 0.1,
  "left_expansion_ratio": 0.1,
  "right_expansion_ratio": 0.1,
  "prompt": "extend the soft studio background",
  "n": 1
}'
{
  "code": 123,
  "message": "<string>",
  "data": {
    "task_id": "<string>",
    "created_at": 123,
    "updated_at": 123,
    "task_status_msg": "<string>",
    "task_info": {
      "external_task_id": "<string>"
    },
    "task_result": {}
  },
  "request_id": "<string>"
}
Use this endpoint to outpaint an image beyond its original borders when you need more canvas around the source content.

How the expansion ratios work

  • Each ratio is measured against the original width or height
  • The combined expanded canvas must still stay within Kling’s documented area limits
  • Start with small values such as 0.1 on each side before attempting larger expansions

Request flow

  • Send all four ratio fields, using 0 for any side you do not want to expand
  • Save the returned task_id
  • Poll the matching Kling image query path until the task reaches a terminal state
For the complete parameter reference, see the official Kling documentation.

Authorizations

Authorization
string
header
required

Bearer token authentication. Use your CometAPI key.

Headers

Content-Type
string
default:application/json

Must be application/json.

Body

application/json
image
string
required

Source image to expand. Image URL or raw Base64 string without a data: prefix. Supported formats: JPG, JPEG, PNG. Maximum 10 MB, minimum 300x300 px, aspect ratio between 1:2.5 and 2.5:1.

up_expansion_ratio
number
required

Upward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Required range: 0 <= x <= 2
down_expansion_ratio
number
required

Downward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Required range: 0 <= x <= 2
left_expansion_ratio
number
required

Leftward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Required range: 0 <= x <= 2
right_expansion_ratio
number
required

Rightward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Required range: 0 <= x <= 2
prompt
string

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

n
integer
default:1

Number of expanded images to generate. Range: 1-9.

Required range: 1 <= x <= 9
watermark_info
object

Watermark options.

callback_url
string

Webhook URL for task status notifications.

external_task_id
string

Optional user-defined task ID for your own tracking. Must be unique per account.

Response

200 - application/json

Task request accepted or an error response returned by the API.

code
required

Response code. 0 means the task request was accepted.

message
string
required

Response message.

data
object
required
request_id
string

Request identifier returned when present.