图像生成
POST /kling/v1/images/generations
说明
其他参数 请看 官方文档 https://app.klingai.com/cn/dev/document-api/apiReference/updateNotice 参数是一致的,对接时,仅需将请求域名、API key 改成我们
概览
| Method | POST |
|---|---|
| Path | /kling/v1/images/generations |
| Type | http |
| Status | 1 |
| Module | 2102810 |
| Folder | 46920504 |
参数
{ "query": [], "path": [], "cookie": [], "header": [ { "id": "NQs7bxnpZf", "name": "Content-Type", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "id": "qb8tEQbCty", "name": "Accept", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "required": true, "description": "", "type": "string", "id": "gBxcCbXhsa", "enable": true, "name": "Authorization", "sampleValue": "Bearer {{YOUR_API_KEY}}" } ] }
请求体
{ "type": "application/json", "parameters": [], "jsonSchema": { "type": "object", "properties": { "prompt": { "description": "正向提示词,必需,描述你想要生成的图像内容,不能超过500个字符", "type": "string" }, "negative_prompt": { "description": "负向提示词,可选,描述你不想在图像中出现的元素,不能超过200个字符", "type": "string" }, "image": { "description": "参考图片,可选,支持 Base64 编码或图片 URL,支持 .jpg/.jpeg/.png 格式,大小不能超过 10MB", "type": "string" }, "image_fidelity": { "description": "参考图片的影响强度,可选,取值范围:0-1,值越大,生成的图像越接近参考图片", "type": "number" }, "n": { "description": "生成图片的数量,可选,取值范围:1-9", "type": "integer" }, "aspect_ratio": { "description": "生成图片的纵横比,可选,可选值:16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3", "type": "string" }, "callback_url": { "description": "回调通知地址,可选,当任务状态发生变化时,系统会向这个地址发送通知", "type": "string" }, "model_name": { "description": "kling-v1、kling-v1-5、kling-v1-6\n", "type": "string" } }, "required": [ "model_name", "prompt", "negative_prompt", "image", "image_fidelity", "n", "aspect_ratio", "callback_url" ], "x-apifox-orders": [ "model_name", "prompt", "negative_prompt", "image", "image_fidelity", "n", "aspect_ratio", "callback_url" ] }, "mediaType": "", "examples": [ { "value": "{\n \"model_name\": \"kling-v1-5\",\n \"prompt\": \"flow\",\n \"negative_prompt\": \"\",\n \"image\": \"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==\",\n \"aspect_ratio\": \"1:1\",\n \"human_fidelity\": 1,\n \"image_reference\": \"subject\"\n}", "mediaType": "application/json", "description": "" } ], "oasExtensions": "" }
响应
[ { "id": 582215340, "name": "成功", "code": 200, "contentType": "json", "jsonSchema": { "type": "object", "properties": { "code": { "type": "integer" }, "message": { "type": "string" }, "request_id": { "type": "string" }, "data": { "type": "object", "properties": { "task_id": { "type": "string" }, "task_status": { "type": "string" }, "created_at": { "type": "integer" }, "updated_at": { "type": "integer" } }, "required": [ "task_id", "task_status", "created_at", "updated_at" ] } }, "required": [ "code", "message", "request_id", "data" ] }, "itemSchema": {}, "description": "", "mediaType": "", "headers": [], "oasExtensions": "" } ]
响应示例
[ { "name": "成功示例", "responseId": 582215340, "data": "{\r\n \"code\": 0,\r\n \"message\": \"SUCCEED\",\r\n \"request_id\": \"CjMT7WdSwWcAAAAAALvB3g\",\r\n \"data\": {\r\n \"task_id\": \"CjMT7WdSwWcAAAAAALvB3g\",\r\n \"task_status\": \"submitted\",\r\n \"created_at\": 1733851336696,\r\n \"updated_at\": 1733851336696\r\n }\r\n}", "description": "", "oasKey": "", "oasExtensions": "", "id": 454731945 } ]