Skip to main content
POST
cURL
當你希望 Kling 根據多個主體參考,再加上可選的場景或風格參考來產生一張圖像時,請使用此端點。

呼叫前準備

  • subject_image_list 中提供 1 到 4 張圖片
  • 新請求請使用 model_name: kling-v2-1
  • 只有在核心主體構圖已經可行時,才加入 scene_imagestyle_image
  • 將此視為非同步產生路由,並保存回傳的 task id

任務流程

1

提交圖像產生任務

傳送主體圖片清單與 prompt,然後儲存回傳的 task id。
2

輪詢任務

使用對應的 Kling 圖像查詢路徑輪詢回傳的任務,直到任務進入終止狀態。
3

保存結果

如果你需要持久存取,請將產生的圖像儲存到你自己的儲存空間中。
如需完整的參數參考,請參閱官方 Kling 文件

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

標頭

Content-Type
string
預設值:application/json

Must be application/json.

主體

application/json
subject_image_list
object[]
必填

Subject reference images. Minimum 1, maximum 4.

Required array length: 1 - 4 elements
model_name
enum<string>
預設值:kling-v2

Model to use for multi-image generation. Use kling-v2-1 for new requests; omitting the field uses the legacy route default.

可用選項:
kling-v2,
kling-v2-1
prompt
string

Text prompt describing the desired output. Maximum 2500 characters.

negative_prompt
string

Elements to exclude from the image. Maximum 2500 characters.

scene_image
string

Optional scene reference image. 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.

style_image
string

Optional style reference image. 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.

n
integer
預設值:1

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

必填範圍: 1 <= x <= 9
aspect_ratio
enum<string>
預設值:16:9

Aspect ratio of the generated image.

可用選項:
16:9,
9:16,
1:1,
4:3,
3:4,
3:2,
2:3,
21: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.