Documentation

图片生成

Last updated: Nov 4, 2026

POST
/v3/aigc/kl/images/generations

文生图 / 图生图,支持角色特征或人物长相参考。

使用 TE 北京地域 API Key 鉴权。模型能力、调用约定见 Kling 接口概览。

Authorization

BearerAuth
headerAuthorizationBearer <token>

TE 北京地域 API Key,填写后自动添加 Bearer 前缀。

Request Body

application/json
  1. body
model_name?string

kling-v1(默认)、kling-v1-5、kling-v2、kling-v2-new、kling-v2-1、kling-v3

prompt*string

≤ 2500 字符

negative_prompt?string

≤ 2500 字符;图生图时不支持

image?string

参考图,URL 或 Base64(不带 data: 前缀);jpg/jpeg/png,≤ 10MB,宽高 ≥ 300px,宽高比 1:2.5~2.5:1;image_reference 不为空时必填

image_reference?string

subject 角色特征、face 人物长相(仅 1 张人脸);kling-v1-5 且 image 不为空时必填

image_fidelity?number

[0,1],默认 0.5;仅 kling-v1、kling-v1-5

human_fidelity?number

[0,1],默认 0.45;仅 kling-v1-5 且 image_reference 为 subject

element_list?array<>

主体 [{element_id}];图片 + 主体 ≤ 10

resolution?string

1k(默认)、2k

n?integer

[1,9],默认 1

aspect_ratio?string

16:9(默认)、9:16、1:1、4:3、3:4、3:2、2:3、21:9

watermark_info?

{"enabled": true} 同时生成含水印结果;不支持自定义水印

Response Body

成功;具体状态及结果见响应字段。

application/json
  1. response
taskId?string

任务 ID

requestId?string

请求 ID,用于排查

code?string

错误码,异常时返回

message?string

错误信息,异常时返回

Example Request
curl -X POST 'https://vod.bj.baidubce.com/v3/aigc/kl/images/generations' \  -H 'Content-Type: application/json' \  -d '{  "model_name": "kling-v3",  "prompt": "Generate a recommended cover for each subject based on the style of the reference image",  "element_list": [    {      "element_id": "160"    },    {      "element_id": "161"    }  ],  "image": "https://example.com/style.png",  "resolution": "2k",  "n": 2,  "aspect_ratio": "1:1",  "watermark_info": {    "enabled": true  }}'
Example Response200
{  "taskId": "tsk-xxxxxxxxxxxxxxxx",  "requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}