Skip to main content
POST
cURL
当你希望 Kling 基于多个主体参考图,再结合可选的场景或风格参考图生成一张图像时,请使用此端点。

调用前准备

  • subject_image_list 中提供 1 到 4 张图片
  • 新请求使用 model_name: kling-v2-1
  • 仅当核心主体构图已满足需求时,再添加 scene_imagestyle_image
  • 将其视为异步生成路由,并保存返回的任务 id

任务流程

1

提交图像生成任务

发送主体图片列表和 prompt,然后保存返回的任务 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.