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.