Skip to main content
POST
cURL
Sử dụng endpoint này để outpaint một hình ảnh vượt ra ngoài các viền gốc của nó khi bạn cần thêm vùng canvas xung quanh nội dung nguồn.

Cách các tỷ lệ mở rộng hoạt động

  • Mỗi tỷ lệ được đo dựa trên chiều rộng hoặc chiều cao gốc
  • Vùng canvas mở rộng kết hợp vẫn phải nằm trong giới hạn diện tích được Kling ghi rõ trong tài liệu
  • Hãy bắt đầu với các giá trị nhỏ như 0.1 cho mỗi cạnh trước khi thử các mức mở rộng lớn hơn

Luồng request

  • Gửi cả bốn trường tỷ lệ, dùng 0 cho bất kỳ cạnh nào bạn không muốn mở rộng
  • Lưu task_id được trả về
  • Poll đường dẫn truy vấn hình ảnh Kling tương ứng cho đến khi task đạt trạng thái kết thúc
Để xem tài liệu tham chiếu tham số đầy đủ, hãy xem tài liệu Kling chính thức.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Tiêu đề

Content-Type
string
mặc định:application/json

Must be application/json.

Nội dung

application/json
image
string
bắt buộc

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
bắt buộc

Upward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Phạm vi bắt buộc: 0 <= x <= 2
down_expansion_ratio
number
bắt buộc

Downward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Phạm vi bắt buộc: 0 <= x <= 2
left_expansion_ratio
number
bắt buộc

Leftward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Phạm vi bắt buộc: 0 <= x <= 2
right_expansion_ratio
number
bắt buộc

Rightward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.

Phạm vi bắt buộc: 0 <= x <= 2
prompt
string

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

n
integer
mặc định:1

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

Phạm vi bắt buộc: 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.

Phản hồi

200 - application/json

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

code
bắt buộc

Response code. 0 means the task request was accepted.

message
string
bắt buộc

Response message.

data
object
bắt buộc
request_id
string

Request identifier returned when present.