图像生成

POST /kling/v1/images/generations

MethodPOST
Path/kling/v1/images/generations
Typehttp
Status-1
Module2102810
Folder72868072

概览

MethodPOST
Path/kling/v1/images/generations
Typehttp
Status-1
Module2102810
Folder72868072

参数

{
  "header": [
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "KhVJoFPZ8L",
      "enable": true,
      "name": "Content-Type",
      "sampleValue": "application/json"
    },
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "z1jiVngvcv",
      "enable": true,
      "name": "Authorization",
      "sampleValue": "Bearer {{YOUR_API_KEY}}"
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "uxiCrq15Cj",
      "enable": true,
      "name": "model_name",
      "sampleValue": "kling-v1"
    },
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "Bp5PLaF0ag",
      "enable": true,
      "name": "prompt",
      "sampleValue": "生成一张海边的图"
    }
  ],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "model_name": {
        "type": "string",
        "description": "模型名称 枚举值:kling-v1, kling-v1-5, kling-v2, kling-v2-new, kling-v2-1,kling-v3"
      },
      "prompt": {
        "type": "string",
        "description": "正向文本提示词 不能超过2500个字符"
      },
      "negative_prompt": {
        "type": "string",
        "description": "负向文本提示词 不能超过2500个字符"
      },
      "image": {
        "type": "string",
        "description": "参考图像支持传入图片Base64编码或图片URL(确保可访问)"
      },
      "image_reference": {
        "type": "string",
        "description": "图片参考类型\n枚举值:subject(角色特征参考), face(人物长相参考)\n使用face(人物长相参考)时,上传图片需仅含1张人脸。\n使用 kling-v1-5 且 image 参数不为空时,当前参数必填"
      },
      "image_fidelity": {
        "type": "number",
        "description": "生成过程中对用户上传图片的参考强度\n取值范围:[0,1],数值越大参考强度越大"
      },
      "human_fidelity": {
        "type": "number",
        "description": "面部参考强度,即参考图中人物五官相似度\n仅 image_reference 参数为 subject 时生效\n取值范围:[0,1],数值越大参考强度越大"
      },
      "resolution": {
        "type": "string",
        "description": "生成图片的清晰度\n枚举值:1k, 2k\n1k:1K标清\n2k:2K高清"
      },
      "n": {
        "type": "integer",
        "description": "生成图片数量\n取值范围:[1,9]"
      },
      "aspect_ratio": {
        "type": "string",
        "description": "生成图片的画面纵横比(宽:高)\n枚举值:16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9"
      },
      "callback_url": {
        "type": "string"
      }
    },
    "required": [
      "model_name",
      "prompt",
      "n"
    ],
    "x-apifox-orders": [
      "model_name",
      "prompt",
      "negative_prompt",
      "image",
      "image_reference",
      "image_fidelity",
      "human_fidelity",
      "resolution",
      "n",
      "aspect_ratio",
      "callback_url"
    ]
  },
  "required": true,
  "mediaType": "",
  "examples": [
    {
      "mediaType": "application/json",
      "value": "{\r\n    \"model_name\": \"kling-v1\",\r\n    \"prompt\": \"生成一张海边的图\",\r\n    \"negative_prompt\": \"\",\r\n    \"image\": \"\",\r\n    \"image_reference\": \"\",\r\n    // \"image_fidelity\": \"0.5\",\r\n    \"human_fidelity\": 0.45,\r\n    \"resolution\": \"1k\",\r\n    \"n\": 2,\r\n    \"aspect_ratio\": \"16:9\",\r\n    \"callback_url\": \"\"\r\n}"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 111750964,
    "name": "成功",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": []
  }
]