跳轉到主要內容
POST
/
kling
/
v1
/
images
/
editing
/
expand
Request a Kling image-expansion task
curl --request POST \
  --url https://api.cometapi.com/kling/v1/images/editing/expand \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "image": "https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg",
  "up_expansion_ratio": 0.1,
  "right_expansion_ratio": 0.1,
  "left_expansion_ratio": 0.1,
  "bottom_expansion_ratio": 0.1
}
'
{
  "code": 123,
  "message": "<string>",
  "data": {
    "task_id": "<string>",
    "task_status": "<string>",
    "created_at": 123,
    "updated_at": 123
  },
  "request_id": "<string>"
}
當你需要在來源內容周圍擴增更多畫布時,可使用此端點將圖片向原始邊界之外進行外延擴展。

擴展比例的運作方式

  • 每個比例都是相對於原始寬度或高度來計算
  • 擴展後的合併畫布仍必須符合 Kling 文件中記載的面積限制
  • 建議先從每側 0.1 這類較小的數值開始,再嘗試更大的擴展範圍

目前的封裝狀態

  • 文件中的路由為 POST /kling/v1/images/editing/expand
  • 在 2026-03-13 的即時驗證中,對最小請求回傳了 {"code": null, "message": "404"}
  • 在再次驗證之前,請將此端點視為已有文件記載,但目前於 CometAPI 封裝中尚不可用
在將此路由整合進正式環境流程之前,請先確認目前封裝是否可用。
完整參數參考請參閱 Kling 官方文件

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

標頭

Content-Type
string

Optional content type header.

主體

application/json
image
string
預設值:https://cdn.britannica.com/70/234870-050-D4D024BB/Orange-colored-cat-yawns-displaying-teeth.jpg
必填

Source image to expand. Accepts an image URL or raw Base64 string (no data: prefix). Supported formats: JPG, JPEG, PNG. Max 10 MB, minimum 300×300 px, aspect ratio between 1:2.5 and 2.5:1.

up_expansion_ratio
number
預設值:1
必填

Upward expansion as a multiple of the original image height. Range: 0–2. The resulting image area must not exceed 3× the original.

right_expansion_ratio
number
預設值:1
必填

Rightward expansion as a multiple of the original image width. Range: 0–2. The resulting image area must not exceed 3× the original.

left_expansion_ratio
number
預設值:1
必填

Leftward expansion as a multiple of the original image width. Range: 0–2. The resulting image area must not exceed 3× the original.

bottom_expansion_ratio
number
預設值:1
必填

Downward expansion as a multiple of the original image height. Range: 0–2. The resulting image area must not exceed 3× the original.

prompt
string

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

n
string

Number of expanded images to generate.

callback_url
string

Webhook URL for task status notifications. The server sends a callback when the task status changes.

external_task_id
string

Optional user-defined task ID for your own tracking. Does not replace the system-generated task ID. Must be unique per account.

回應

Task accepted when the wrapper route is available.

code
integer
必填

Error code; specifically define the error code

message
string
必填

error message

data
object
必填
request_id
string

Request ID, system-generated, for tracking requests, troubleshooting issues