# Kling v3 视频生成任务

> 视频生成

提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。

## 请求地址

`POST https://api.modelverse.cn/v1/tasks/submit`

## 请求体

## 响应

- **200** — 任务提交成功。
- **400** — 请求参数无效或任务创建失败。
- **default** — 错误响应。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "Kling v3 视频生成接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `Kling-v3` 的视频接口文档，说明如何提交生成任务、查询任务状态、读取视频结果以及处理错误。\n接口路径包括 `POST /v1/tasks/submit`、`GET /v1/tasks/status`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "本模型使用的 ModelVerse 接口地址。"
    }
  ],
  "tags": [
    {
      "name": "Kling/v3",
      "description": "Kling/v3 的异步视频任务接口。"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/tasks/submit": {
      "post": {
        "tags": [
          "Kling/v3"
        ],
        "operationId": "submitKlingV3Task",
        "summary": "Kling v3 视频生成任务",
        "description": "提交异步任务。请求体中的模型和参数按本模型文档填写，响应会返回任务 ID。\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KlingV3TaskSubmitRequest"
              },
              "examples": {
                "textToVideo": {
                  "summary": "文生视频",
                  "value": {
                    "model": "kling-v3",
                    "input": {
                      "prompt": "美丽的海上日落，海浪轻轻拍打岸边"
                    },
                    "parameters": {
                      "kling_v3_type": "t2v",
                      "mode": "pro",
                      "aspect_ratio": "16:9",
                      "duration": 5,
                      "sound": "on"
                    }
                  }
                },
                "imageToVideo": {
                  "summary": "使用首帧图片生成视频",
                  "value": {
                    "model": "kling-v3",
                    "input": {
                      "prompt": "画面中的人物开始自然、轻柔地活动"
                    },
                    "parameters": {
                      "kling_v3_type": "i2v",
                      "mode": "pro",
                      "duration": 5,
                      "image": "https://example.com/first_frame.jpg"
                    }
                  }
                },
                "firstAndTailFrames": {
                  "summary": "使用首尾帧图片生成视频",
                  "value": {
                    "model": "kling-v3",
                    "input": {
                      "prompt": "一个女孩漫步在花园中"
                    },
                    "parameters": {
                      "kling_v3_type": "i2v",
                      "mode": "pro",
                      "duration": 5,
                      "image": "https://example.com/first_frame.jpg",
                      "image_tail": "https://example.com/last_frame.jpg"
                    }
                  }
                },
                "multiShotTextToVideo": {
                  "summary": "多镜头文生视频",
                  "value": {
                    "model": "kling-v3",
                    "parameters": {
                      "kling_v3_type": "t2v",
                      "mode": "pro",
                      "aspect_ratio": "16:9",
                      "duration": 5,
                      "multi_shot": true,
                      "shot_type": "customize",
                      "multi_prompt": [
                        {
                          "index": 1,
                          "prompt": "清晨，一个人行走在薄雾笼罩的森林中",
                          "duration": "2"
                        },
                        {
                          "index": 2,
                          "prompt": "一辆汽车在雨中的街道上疾驰，车灯明亮",
                          "duration": "3"
                        }
                      ],
                      "sound": "on"
                    }
                  }
                },
                "motionControl": {
                  "summary": "使用参考图片和参考视频进行运动控制",
                  "value": {
                    "model": "kling-v3",
                    "input": {
                      "img_url": "https://example.com/character.jpg",
                      "video_url": "https://example.com/motion_reference.mp4",
                      "prompt": "一个人优雅地跳舞"
                    },
                    "parameters": {
                      "kling_v3_type": "motion_control",
                      "duration": 5,
                      "aspect_ratio": "16:9",
                      "character_orientation": "image",
                      "mode": "std"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务提交成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KlingV3TaskSubmitResponse"
                },
                "examples": {
                  "submitted": {
                    "summary": "已提交任务",
                    "value": {
                      "output": {
                        "task_id": "task_id"
                      },
                      "request_id": "request_id"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效或任务创建失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KlingV3ErrorResponse"
                },
                "examples": {
                  "taskCreationError": {
                    "$ref": "#/components/examples/KlingV3TaskCreationError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KlingV3ErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/KlingV3TaskCreationError"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/status": {
      "get": {
        "tags": [
          "Kling/v3"
        ],
        "operationId": "getKlingV3TaskStatus",
        "summary": "查询 Kling v3 任务状态",
        "description": "查询异步任务状态。任务完成后，响应中会包含结果 URL、用量信息或错误信息。\n",
        "parameters": [
          {
            "name": "task_id",
            "in": "query",
            "required": true,
            "description": "提交任务接口 `/v1/tasks/submit` 返回的异步任务 ID。",
            "schema": {
              "type": "string"
            },
            "examples": {
              "documented": {
                "summary": "源文档占位值",
                "value": "task_id"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务状态响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KlingV3TaskStatusResponse"
                },
                "examples": {
                  "success": {
                    "summary": "成功任务",
                    "value": {
                      "output": {
                        "task_id": "task_id",
                        "task_status": "Success",
                        "urls": [
                          "https://xxxxx/xxxx.mp4"
                        ],
                        "submit_time": 1756959000,
                        "finish_time": 1756959050
                      },
                      "usage": {
                        "duration": 5
                      },
                      "request_id": ""
                    }
                  },
                  "failure": {
                    "summary": "失败任务",
                    "value": {
                      "output": {
                        "task_id": "task_id",
                        "task_status": "Failure",
                        "submit_time": 1756959000,
                        "finish_time": 1756959019,
                        "error_message": "error_message"
                      },
                      "usage": {
                        "duration": 5
                      },
                      "request_id": ""
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "任务标识无效或任务状态查询失败。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KlingV3ErrorResponse"
                },
                "examples": {
                  "taskResponseError": {
                    "$ref": "#/components/examples/KlingV3TaskResponseError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KlingV3ErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/KlingV3TaskResponseError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "在 Authorization 请求头中使用 Bearer 方式传入 ModelVerse API 密钥。\n"
      }
    },
    "schemas": {
      "KlingV3TaskSubmitRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "kling-v3",
            "description": "模型名称，固定为 `kling-v3`。"
          },
          "input": {
            "$ref": "#/components/schemas/KlingV3Input"
          },
          "parameters": {
            "$ref": "#/components/schemas/KlingV3Parameters"
          }
        }
      },
      "KlingV3Input": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "prompt": {
            "type": "string",
            "maxLength": 2500,
            "description": "用于指导视频生成的提示词，最多 2500 个字符。文生视频和图生视频模式下，\n当 `parameters.multi_shot` 为 `false` 时必填；运动控制模式下可选。\n",
            "examples": [
              "美丽的海上日落，海浪轻轻拍打岸边"
            ]
          },
          "negative_prompt": {
            "type": "string",
            "maxLength": 2500,
            "description": "用于限制不期望内容的负向提示词。"
          },
          "img_url": {
            "type": "string",
            "minLength": 1,
            "description": "参考图片 URL 或不带数据头的 Base64 编码。运动控制模式下必须与\n`input.video_url` 同时传入；未传 `input.video_url` 时，该字段可作为\n首帧图片，使服务自动选择图生视频模式。\n",
            "examples": [
              "https://example.com/character.jpg"
            ]
          },
          "video_url": {
            "type": "string",
            "format": "uri",
            "description": "运动控制模式使用的参考视频 URL。支持 MP4 和 MOV 格式，文件不得超过\n100MB，宽高须在 340～3850 像素之间。视频时长不得少于 3 秒；\n横屏视频最长 30 秒，竖屏视频最长 10 秒。\n",
            "examples": [
              "https://example.com/motion_reference.mp4"
            ]
          },
          "first_frame_url": {
            "type": "string",
            "format": "uri",
            "description": "首帧图片 URL。传入该字段时，服务可自动选择图生视频模式。\n"
          },
          "images": {
            "type": "array",
            "description": "首帧图片列表。传入该字段时，服务可自动选择图生视频模式。\n",
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      },
      "KlingV3Parameters": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kling_v3_type": {
            "type": "string",
            "description": "显式指定生成类型。未传时，若存在 `input.video_url`，服务选择运动控制；\n若存在任一首帧图片字段，服务选择图生视频；否则选择文生视频。\n",
            "enum": [
              "t2v",
              "i2v",
              "motion_control"
            ]
          },
          "mode": {
            "type": "string",
            "description": "生成质量模式，`std` 为标准模式（720P），`pro` 为专业模式（1080P），`4k` 生成视频质量更佳，输出视频分辨率为4K。",
            "enum": [
              "std",
              "pro",
              "4k"
            ],
            "default": "std"
          },
          "aspect_ratio": {
            "type": "string",
            "description": "生成视频的宽高比。图生视频模式下忽略该参数，以输入图片的宽高比为准。\n",
            "enum": [
              "16:9",
              "9:16",
              "1:1"
            ],
            "default": "16:9"
          },
          "duration": {
            "type": "integer",
            "minimum": 3,
            "maximum": 15,
            "default": 5,
            "description": "生成视频的时长，单位为秒。文生视频和图生视频支持 3～15 秒；\n运动控制支持 5 秒或 10 秒。\n"
          },
          "watermark_enabled": {
            "type": "boolean",
            "description": "是否为生成结果添加水印。"
          },
          "external_task_id": {
            "type": "string",
            "description": "用户自定义任务 ID，不会覆盖系统生成的任务 ID，但可用于查询任务。\n该 ID 在单个用户下必须唯一。\n"
          },
          "image": {
            "type": "string",
            "minLength": 1,
            "description": "图生视频模式使用的首帧参考图片。支持可公开访问的图片 URL 或不带数据头的\nBase64 编码；使用 Base64 时不要包含 `data:image/...;base64,` 前缀。\n支持 JPG、JPEG 和 PNG 格式，文件不得超过 10MB，宽高均不得小于\n300 像素，宽高比须在 1:2.5～2.5:1 之间。\n",
            "examples": [
              "https://example.com/first_frame.jpg"
            ]
          },
          "image_tail": {
            "type": "string",
            "minLength": 1,
            "description": "用于首尾帧控制的尾帧参考图片，必须与 `parameters.image` 同时使用。\nURL、Base64、格式、文件大小、图片尺寸和宽高比要求与首帧图片相同。\n",
            "examples": [
              "https://example.com/last_frame.jpg"
            ]
          },
          "sound": {
            "type": "string",
            "description": "文生视频或图生视频模式下是否为结果生成声音。",
            "enum": [
              "on",
              "off"
            ],
            "default": "off"
          },
          "multi_shot": {
            "type": "boolean",
            "default": false,
            "description": "是否启用多镜头模式。为 `true` 时忽略 `input.prompt`；为 `false` 时\n忽略 `parameters.shot_type` 和 `parameters.multi_prompt`。\n"
          },
          "shot_type": {
            "type": "string",
            "description": "镜头类型。`multi_shot` 为 `true` 时必填。",
            "enum": [
              "customize"
            ]
          },
          "multi_prompt": {
            "type": "array",
            "minItems": 1,
            "maxItems": 6,
            "description": "自定义多镜头提示词列表。当 `multi_shot` 为 `true` 且 `shot_type` 为\n`customize` 时必填。每个镜头至少 1 秒且不得超过视频总时长，所有镜头\n时长之和必须等于视频总时长。\n",
            "items": {
              "$ref": "#/components/schemas/KlingV3MultiPromptItem"
            }
          },
          "character_orientation": {
            "type": "string",
            "description": "运动控制模式下的角色朝向，运动控制模式必填。`image` 表示与参考图片\n朝向一致，`video` 表示与参考视频朝向一致。\n",
            "enum": [
              "image",
              "video"
            ]
          },
          "keep_original_sound": {
            "type": "string",
            "description": "是否保留参考视频的原声。",
            "enum": [
              "yes",
              "no"
            ],
            "default": "yes"
          }
        },
        "dependentRequired": {
          "image_tail": [
            "image"
          ]
        }
      },
      "KlingV3MultiPromptItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "index",
          "prompt",
          "duration"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 1,
            "description": "镜头序号，从 1 开始。"
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "当前镜头的提示词。"
          },
          "duration": {
            "type": "string",
            "minLength": 1,
            "description": "当前镜头的时长，单位为秒，以字符串形式传入。"
          }
        }
      },
      "KlingV3TaskSubmitResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "$ref": "#/components/schemas/KlingV3TaskSubmitOutput"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "KlingV3TaskSubmitOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "task_id"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "异步任务唯一标识。"
          }
        }
      },
      "KlingV3TaskStatusResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "$ref": "#/components/schemas/KlingV3TaskStatusOutput"
          },
          "usage": {
            "$ref": "#/components/schemas/KlingV3Usage"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "KlingV3TaskStatusOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "task_id",
          "task_status"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "异步任务唯一标识。"
          },
          "task_status": {
            "$ref": "#/components/schemas/KlingV3TaskStatus"
          },
          "urls": {
            "type": "array",
            "description": "视频结果 URL 列表。",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "submit_time": {
            "type": "integer",
            "format": "int64",
            "description": "任务提交时间的 Unix 秒级时间戳。"
          },
          "finish_time": {
            "type": "integer",
            "format": "int64",
            "description": "任务完成时间的 Unix 秒级时间戳。"
          },
          "error_message": {
            "type": "string",
            "description": "任务失败时返回的错误信息。"
          }
        }
      },
      "KlingV3TaskStatus": {
        "type": "string",
        "description": "查询异步任务状态。任务完成后，响应中会包含结果 URL、用量信息或错误信息。\n",
        "enum": [
          "Pending",
          "Running",
          "Success",
          "Failure"
        ]
      },
      "KlingV3Usage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "duration": {
            "type": "integer",
            "description": "生成视频的时长，单位为秒。"
          }
        }
      },
      "KlingV3ErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/KlingV3ErrorObject"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识，如可用。"
          }
        }
      },
      "KlingV3ErrorObject": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "message",
          "type"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "错误信息。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "错误码：`006001094` 表示任务资源不足，`006001095` 表示任务响应错误，\n`006001099` 表示任务创建错误。\n",
            "examples": [
              "006001099"
            ]
          },
          "param": {
            "type": [
              "string",
              "null"
            ],
            "description": "相关请求参数，如有。"
          }
        }
      }
    },
    "examples": {
      "KlingV3TaskCreationError": {
        "summary": "任务创建错误",
        "value": {
          "error": {
            "message": "任务创建错误",
            "type": "invalid_request_error",
            "code": "006001099",
            "param": null
          },
          "request_id": "request_id"
        }
      },
      "KlingV3TaskResponseError": {
        "summary": "任务响应错误",
        "value": {
          "error": {
            "message": "任务响应错误",
            "type": "invalid_request_error",
            "code": "006001095",
            "param": null
          },
          "request_id": "request_id"
        }
      }
    }
  }
}
```
