Skip to main content
POST
cURL
当你需要在源内容周围获得更多画布空间时,可使用此端点将图像在原始边界之外进行外绘扩展。

扩展比例的工作方式

  • 每个比例都相对于原始宽度或高度来计算
  • 扩展后的组合画布仍必须保持在 Kling 文档规定的面积限制内
  • 在尝试更大范围的扩展之前,先从每一侧使用 0.1 这类较小的值开始

请求流程

  • 发送全部四个比例字段,对于不希望扩展的任意一侧使用 0
  • 保存返回的 task_id
  • 轮询对应的 Kling 图像查询路径,直到任务进入终态
有关完整的参数参考,请参阅官方 Kling 文档

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

请求头

Content-Type
string
默认值:application/json

Must be application/json.

请求体

application/json
image
string
必填

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
必填

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 <= 2
down_expansion_ratio
number
必填

Downward 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 <= 2
left_expansion_ratio
number
必填

Leftward 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 <= 2
right_expansion_ratio
number
必填

Rightward 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 <= 2
prompt
string

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

n
integer
默认值:1

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

必填范围: 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.

响应

200 - application/json

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

code
必填

Response code. 0 means the task request was accepted.

message
string
必填

Response message.

data
object
必填
request_id
string

Request identifier returned when present.