Expand an image with Kling
Use Kling Image Expansion API via CometAPI to expand images beyond their original borders with controllable outpainting.
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.1on each side before attempting larger expansions
Request flow
- Send all four ratio fields, using
0for 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
Authorizations
Bearer token authentication. Use your CometAPI key.
Headers
Must be application/json.
Body
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.
Upward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Downward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Leftward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Rightward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Optional text prompt to guide the expanded area content. Maximum 2500 characters.
Number of expanded images to generate. Range: 1-9.
1 <= x <= 9Watermark options.
Webhook URL for task status notifications.
Optional user-defined task ID for your own tracking. Must be unique per account.