文生视频

POST /kling/v1/videos/text2video

MethodPOST
Path/kling/v1/videos/text2video
Typehttp
Status1
Module2102810
Folder72869254

概览

MethodPOST
Path/kling/v1/videos/text2video
Typehttp
Status1
Module2102810
Folder72869254

参数

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

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "model_name": {
        "type": "string",
        "description": " 模型名称 枚举值:kling-v1,kling-v1-6, kling-v2-master, kling-v2-1-master, kling-v2-5-turbo,kling-v3"
      },
      "prompt": {
        "type": "string",
        "description": "正向文本提示词不能超过2500个字符"
      },
      "multi_shot": {
        "type": "boolean",
        "description": "是否生成多镜头视频\n当前参数为true时,prompt参数无效\n当前参数为false时,shot_type参数及multi_prompt参数无效"
      },
      "shot_type": {
        "type": "string",
        "description": "分镜方式\n枚举值:customize\n当multi_shot参数为true时,当前参数必填 "
      },
      "multi_prompt": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "index": {
              "type": "integer"
            },
            "prompt": {
              "type": "string"
            },
            "duration": {
              "type": "string"
            }
          },
          "required": [
            "index",
            "prompt",
            "duration"
          ],
          "x-apifox-orders": [
            "index",
            "prompt",
            "duration"
          ]
        },
        "description": "各分镜信息,如提示词、时长等\n● 通过index、prompt、duration参数定义分镜序号及相应提示词和时长,其中:\n\t○ 最多支持6个分镜,最小支持1个分镜\n\t○ 每个分镜相关内容的最大长度不超过512\n\t○ 每个分镜的时长不大于当前任务的总时长,不小于1\n\t○ 所有分镜的时长之和等于当前任务的总时长"
      },
      "negative_prompt": {
        "type": "string",
        "description": "负向文本提示词不能超过2500个字符"
      },
      "cfg_scale": {
        "type": "number",
        "description": "生成视频的自由度;值越大,模型自由度越小,与用户输入的提示词相关性越强"
      },
      "mode": {
        "type": "string",
        "description": "生成视频的模式\n枚举值:std,pro\n其中std:标准模式(标准),基础模式,性价比高\n其中pro:专家模式(高品质),高表现模式,生成视频质量更佳"
      },
      "sound": {
        "type": "string",
        "description": "生成视频时是否同时生成声音枚举值:on,off仅V2.6及后续版本模型支持当前参数"
      },
      "aspect_ratio": {
        "type": "string",
        "description": "生成视频的画面纵横比(宽:高)"
      },
      "duration": {
        "type": "string",
        "description": "生成视频时长,单位s"
      },
      "callback_url": {
        "type": "string"
      },
      "external_task_id": {
        "type": "string"
      },
      "watermark_info": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "enabled"
        ],
        "x-apifox-orders": [
          "enabled"
        ],
        "description": "是否同时生成含水印的结果\n● 通过enabled参数定义,用key:value承载,如下::\n\"watermark_info\": {\n \t\"enabled\": boolean // true 为生成,false 为不生成\n}"
      },
      "camera_control": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "config": {
            "type": "object",
            "properties": {
              "horizontal": {
                "type": "integer"
              },
              "vertical": {
                "type": "integer"
              },
              "pan": {
                "type": "integer"
              },
              "tilt": {
                "type": "integer"
              },
              "roll": {
                "type": "integer"
              },
              "zoom": {
                "type": "integer"
              }
            },
            "required": [
              "horizontal",
              "vertical",
              "pan",
              "tilt",
              "roll",
              "zoom"
            ],
            "x-apifox-orders": [
              "horizontal",
              "vertical",
              "pan",
              "tilt",
              "roll",
              "zoom"
            ]
          }
        },
        "required": [
          "type",
          "config"
        ],
        "x-apifox-orders": [
          "type",
          "config"
        ],
        "description": "控制摄像机运动的协议(如未指定,模型将根据输入的文本/图片进行智能匹配)"
      }
    },
    "required": [
      "model_name",
      "mode",
      "duration",
      "multi_shot"
    ],
    "x-apifox-orders": [
      "model_name",
      "prompt",
      "multi_shot",
      "shot_type",
      "multi_prompt",
      "negative_prompt",
      "cfg_scale",
      "mode",
      "sound",
      "camera_control",
      "aspect_ratio",
      "duration",
      "watermark_info",
      "callback_url",
      "external_task_id"
    ]
  },
  "required": false,
  "mediaType": "",
  "examples": [
    {
      "mediaType": "application/json",
      "value": "{\r\n    \"model_name\": \"kling-v1\",\r\n    \"prompt\": \"生成一个海边有一个人跳舞的视频\",\r\n    \"negative_prompt\": \"\",\r\n    \"cfg_scale\": 0.5,\r\n    \"mode\": \"std\",\r\n    \"sound\": \"off\",\r\n    \"camera_control\": {\r\n        \"type\": \"simple\",\r\n        \"config\": {\r\n            \"horizontal\": 1.0,\r\n            \"vertical\": 0,\r\n            \"pan\": 0,\r\n            \"tilt\": 0,\r\n            \"roll\": 0,\r\n            \"zoom\": 0\r\n        }\r\n    },\r\n    \"aspect_ratio\": \"16:9\",\r\n    \"duration\": \"5\",\r\n    \"callback_url\": \"\",\r\n    \"external_task_id\": \"\"\r\n}"
    }
  ],
  "oasExtensions": ""
}

响应

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

响应示例

[
  {
    "name": "成功示例",
    "responseId": 124751903,
    "data": "{\r\n    \"code\": 0,\r\n    \"message\": \"SUCCEED\",\r\n    \"request_id\": \"603e2a28-fb89-4146-ae33-412d74012a6d\",\r\n    \"data\": {\r\n        \"task_id\": \"831922345719271433\",\r\n        \"task_status\": \"submitted\",\r\n        \"task_info\": {},\r\n        \"created_at\": 1766374262370,\r\n        \"updated_at\": 1766374262370\r\n    }\r\n}",
    "id": "019b441c-fc37-769a-9ed1-97a911214b27"
  }
]