文生视频

POST /kling/v1/videos/text2video

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

说明

其他参数 请看 官方文档 https://app.klingai.com/cn/dev/document-api/apiReference/updateNotice 参数是一致的,对接时,仅需将请求域名、API key 改成我们

概览

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

参数

{
  "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"
      },
      "cfg_scale": {
        "description": "生成视频的自由度,可选,取值范围0-1,值越大相关性越强",
        "type": "number"
      },
      "mode": {
        "description": "生成视频的模式,可选,std(高性能)或 pro(高表现)",
        "type": "string"
      },
      "camera_control": {
        "type": "object",
        "properties": {
          "type": {
            "description": "摄像机控制类型",
            "type": "string"
          },
          "config": {
            "type": "object",
            "properties": {
              "horizontal": {
                "description": "水平移动",
                "type": "integer"
              },
              "vertical": {
                "description": "垂直移动",
                "type": "integer"
              },
              "pan": {
                "description": "平移",
                "type": "integer"
              },
              "tilt": {
                "description": "倾斜",
                "type": "integer"
              },
              "roll": {
                "description": "旋转",
                "type": "integer"
              },
              "zoom": {
                "description": "缩放",
                "type": "integer"
              }
            },
            "required": [
              "horizontal",
              "vertical",
              "pan",
              "tilt",
              "roll",
              "zoom"
            ],
            "description": "摄像机运动配置,包含六个控制参数",
            "x-apifox-orders": [
              "horizontal",
              "vertical",
              "pan",
              "tilt",
              "roll",
              "zoom"
            ]
          }
        },
        "required": [
          "type",
          "config"
        ],
        "description": "控制摄像机运动的协议,可选,未指定则智能匹配",
        "x-apifox-orders": [
          "type",
          "config"
        ]
      },
      "aspect_ratio": {
        "description": "生成视频的画面纵横比,可选值:16:9, 9:16, 1:1",
        "type": "string"
      },
      "duration": {
        "type": "number",
        "description": "生成视频时长,单位秒,可选值:5或10"
      },
      "callback_url": {
        "description": "回调通知地址,可选,用于接收任务状态更新",
        "type": "string"
      },
      "model_name": {
        "type": "string",
        "description": "kling-v1、kling-v1-5、kling-v1-6、kling-v2-5-turbo\n"
      }
    },
    "required": [
      "model_name",
      "prompt",
      "negative_prompt",
      "cfg_scale",
      "mode",
      "camera_control",
      "aspect_ratio",
      "duration",
      "callback_url"
    ],
    "x-apifox-orders": [
      "model_name",
      "prompt",
      "negative_prompt",
      "cfg_scale",
      "mode",
      "camera_control",
      "aspect_ratio",
      "duration",
      "callback_url"
    ]
  },
  "required": false,
  "mediaType": "",
  "examples": [
    {
      "value": "{\n  \"model_name\":\"kling-v2-5-turbo\",\n  \"prompt\": \"在海滩上度假的快乐场景。\",\n  \"duration\":5,\n  //\"mode\":\"pro\"\n}",
      "mediaType": "application/json",
      "description": ""
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 582256285,
    "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"
            },
            "task_info": {
              "type": "object",
              "properties": {}
            },
            "created_at": {
              "type": "integer"
            },
            "updated_at": {
              "type": "integer"
            }
          },
          "required": [
            "task_id",
            "task_status",
            "task_info",
            "created_at",
            "updated_at"
          ]
        }
      },
      "required": [
        "code",
        "message",
        "request_id",
        "data"
      ]
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": [],
    "oasExtensions": ""
  }
]

响应示例

[
  {
    "name": "成功示例",
    "responseId": 582256285,
    "data": "{\r\n    \"code\": 0,\r\n    \"message\": \"SUCCEED\",\r\n    \"request_id\": \"795f5ea4-7746-4e3a-a184-75d44240f87f\",\r\n    \"data\": {\r\n        \"task_id\": \"814237883686625347\",\r\n        \"task_status\": \"submitted\",\r\n        \"task_info\": {},\r\n        \"created_at\": 1762157958060,\r\n        \"updated_at\": 1762157958060\r\n    }\r\n}",
    "description": "",
    "oasKey": "",
    "oasExtensions": "",
    "id": 454723174
  }
]