Skip to main content
POST
cURL
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.

Last modified on June 26, 2026