使用 Kling 擴展圖片
透過 CometAPI 使用 Kling Image Expansion API,將圖片擴展至原始邊界之外,並可控制外延生成。
擴展比例的運作方式
- 每個比例都是以原始寬度或高度為基準來計算
- 擴展後的合併畫布仍必須符合 Kling 文件中記載的面積限制
- 在嘗試較大的擴展前,請先從每一側使用如
0.1這樣的較小數值開始
請求流程
- 傳送全部四個比例欄位,對於不想擴展的邊請使用
0 - 儲存回傳的
task_id - 輪詢對應的 Kling 圖片查詢路徑,直到任務進入終止狀態
授權
Bearer token authentication. Use your CometAPI key.
標頭
Must be application/json.
主體
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.