> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidgo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling 4.0 视频编辑

> Kling 4.0 视频编辑 API 根据文字指令编辑 3–30 秒的源视频，可选参考图和主体，输出 720p 或 1080p。

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询任务状态](https://docs.vidgo.ai/zh/api-manual/task-management/status.md)接口获取结果。

Kling 4.0 视频编辑根据文字指令修改已有的 3–30 秒视频：改变场景风格、替换物体或背景、调整动作，同时保留源视频的运动。参考图和图片主体可以明确指定要放入的内容。

Kling 4.0 是快手 Kling AI 的视频模型。Vidgo 提供四个 model ID：[文生视频](https://docs.vidgo.ai/zh/api-manual/video-series/kwaivgi-kling-v4-0-text-to-video.md)、[图生视频](https://docs.vidgo.ai/zh/api-manual/video-series/kwaivgi-kling-v4-0-image-to-video.md)、[参考生视频](https://docs.vidgo.ai/zh/api-manual/video-series/kwaivgi-kling-v4-0-reference-to-video.md)和[视频编辑](https://docs.vidgo.ai/zh/api-manual/video-series/kwaivgi-kling-v4-0-video-edit.md)。

## 模型

* **kwaivgi/kling-v4.0/video-edit** — Kling 4.0 视频编辑：用文字指令编辑 3–30 秒的源视频，720p 或 1080p。

## 功能

* 用文字指令编辑 3–30 秒的源视频。
* 可选参考图（`@Image1`……）和图片主体（`@Element1`……）。
* 输出时长默认与源视频一致，也可设置 `duration`。
* 输出 720p 或 1080p。

## 必填参数

* `video_url`（string）：源视频的公开 HTTP(S) URL，3–30 秒，最大 100 MB。
* `prompt`（string）：编辑指令，去除首尾空白后 1–26,000 个字符。

## 可选参数

* `duration`（integer）：输出时长，`3`–`30` 秒。无默认值：省略时输出与源视频时长一致。
* `resolution`（string）：`720p` 或 `1080p`。默认 `720p`。
* `reference_image_urls`（string\[]）：最多 10 个公开 HTTP(S) 图片 URL。
* `kling_elements`（object\[]）：最多 7 个图片主体，每个为包含 2–4 个图片 URL 的 `{element_input_urls}`。此处不支持视频主体。

## 输出

任务完成后，[查询任务状态](https://docs.vidgo.ai/zh/api-manual/task-management/status.md)和回调内容的 `files` 数组中会返回一个带音轨的 MP4 视频。

## 示例

* **改变风格，保持源视频时长**：把街景改成冬季雪景，不传 `duration`，输出时长跟随源视频。
* **用参考图替换物体，带回调**：把手机换成 `@Image1` 中的产品，1080p，10 秒，并提供 `callback_url`。

## 注意事项

* 本 ID 不支持 `multi_prompt`、`image_urls`、`reference_video_urls`、`aspect_ratio` 和视频主体，传入会返回 400。
* 源视频会在服务端下载并检测时长，须为 3–30 秒且不超过 100 MB。
* 上文未列出的字段会返回 400。`model` 和 `callback_url` 放在请求根级，不要放进 `input`。
* 积分在提交时预扣，取决于 `resolution` 和时长。有输入视频时使用单独的输入视频费率，计费秒数 = 输出时长 + max（输出时长，输入视频总时长）；输入视频时长先求和再向上取整到整秒。任务失败会全额退还。当前费率见[定价页](https://vidgo.ai/apis/api-pricing)。未传 `duration` 时，输出时长按源视频时长向上取整计费。
* 仅支持 720p 或 1080p 输出；本模型没有 4K 或 HDR 档位，没有音频开关，也不支持 `seed`。


## OpenAPI

````yaml zh/api-manual/video-series/kwaivgi-kling-v4-0-video-edit.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - Kling 4.0 视频编辑
  description: Kling 4.0 视频编辑 API 根据文字指令编辑 3–30 秒的源视频，可选参考图和主体，输出 720p 或 1080p。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - Video Series
      summary: Kling 4.0 视频编辑
      description: >-
        传 `video_url` 和 `prompt`。不支持
        `multi_prompt`、`image_urls`、`reference_video_urls` 和
        `aspect_ratio`，传入会返回 400。输入视频会在服务端下载并检测时长（每个最大 100 MB）。每个视频须为 3–30
        秒，所有输入视频合计不得超过 30 秒。
      operationId: submit_kwaivgi_kling_v4_0_video_edit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: 模型 ID，填 `kwaivgi/kling-v4.0/video-edit`。
                  example: kwaivgi/kling-v4.0/video-edit
                callback_url:
                  type: string
                  format: uri
                  nullable: true
                  description: >-
                    可选的公开 HTTP(S) 地址，任务变为 `finished` 或 `failed` 时会收到 POST
                    请求。建议使用 HTTPS。省略、传 `null` 或空字符串即不发送回调。
                  example: https://your-domain.com/callback
                input:
                  type: object
                  required:
                    - video_url
                    - prompt
                  properties:
                    video_url:
                      type: string
                      format: uri
                      example: https://example.com/source.mp4
                      description: 源视频的公开 HTTP(S) URL，3–30 秒，最大 100 MB。
                    prompt:
                      type: string
                      minLength: 1
                      maxLength: 26000
                      example: >-
                        Turn the street into a snowy winter evening and keep the
                        people and camera motion unchanged
                      description: >-
                        编辑指令，去除首尾空白后 1–26,000 个字符，描述要对源视频做的修改。本 ID 不支持
                        `multi_prompt`。
                    duration:
                      type: integer
                      minimum: 3
                      maximum: 30
                      description: 输出时长，单位秒（整数，3–30）。省略时与源视频一致，计费按源视频时长向上取整。
                    resolution:
                      type: string
                      enum:
                        - 720p
                        - 1080p
                      default: 720p
                      description: 输出分辨率，决定计费档位。
                    reference_image_urls:
                      type: array
                      items:
                        type: string
                        format: uri
                      maxItems: 10
                      description: >-
                        最多 10 个公开 HTTP(S) 参考图 URL，在提示词中用
                        `@Image1`、`@Image2`……引用。
                    kling_elements:
                      type: array
                      items:
                        type: object
                        required:
                          - element_input_urls
                        properties:
                          element_input_urls:
                            type: array
                            items:
                              type: string
                              format: uri
                            minItems: 2
                            maxItems: 4
                            description: 2–4 个展示同一主体的公开 HTTP(S) 图片 URL。
                        additionalProperties: false
                        description: 一个图片主体。
                      maxItems: 7
                      description: >-
                        最多 7 个图片主体（element）。每个 element 包含 2–4 张图片的
                        `element_input_urls`。本 ID 不支持视频主体。在提示词中按数组顺序用
                        `@Element1`、`@Element2`……引用。
                  additionalProperties: false
                  description: 生成参数。
            examples:
              restyle:
                summary: 改变风格，保持源视频时长
                value:
                  model: kwaivgi/kling-v4.0/video-edit
                  input:
                    video_url: https://example.com/street.mp4
                    prompt: >-
                      Turn the street into a snowy winter evening and keep the
                      people and camera motion unchanged
                    resolution: 720p
              replace_product:
                summary: 用参考图替换物体，带回调
                value:
                  model: kwaivgi/kling-v4.0/video-edit
                  callback_url: https://your-domain.com/callback
                  input:
                    video_url: https://example.com/unboxing.mp4
                    prompt: >-
                      Replace the phone in the hands with the speaker from
                      @Image1, keep lighting and hand motion
                    reference_image_urls:
                      - https://example.com/speaker.png
                    duration: 10
                    resolution: 1080p
      responses:
        '200':
          description: 任务已提交
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - data
                properties:
                  code:
                    type: integer
                    enum:
                      - 200
                    description: HTTP 状态码。
                  data:
                    type: object
                    required:
                      - task_id
                      - status
                      - created_time
                    properties:
                      task_id:
                        type: string
                        description: >-
                          任务
                          ID，用于[查询任务状态](/zh/api-manual/task-management/status)。
                      status:
                        type: string
                        enum:
                          - not_started
                        description: 任务的初始状态。
                      created_time:
                        type: string
                        format: date-time
                        description: 任务创建时间（ISO 8601）。
              example:
                code: 200
                data:
                  task_id: task-unified-1762160000-abc123
                  status: not_started
                  created_time: '2026-11-03T10:30:00'
        '400':
          description: 输入无效、字段不受支持、媒体无法访问或积分不足
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '401':
          description: 凭证无效
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '403':
          description: 拒绝访问
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '404':
          description: 模型未知或已停用
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '408':
          description: 请求超时
          content:
            text/plain:
              schema:
                type: string
              example: Request timeout
        '422':
          description: JSON 无效或请求体不是对象
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '429':
          description: 超出速率限制或 API Key 积分限额
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '500':
          description: 内部错误
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '502':
          description: 无法创建上游生成任务
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
        '503':
          description: 所请求的模型暂时不可用
          content:
            application/json:
              schema:
                type: object
                required:
                  - detail
                properties:
                  detail:
                    oneOf:
                      - type: string
                      - type: object
                        additionalProperties: true
                      - type: array
                        items: {}
                    description: 错误信息。
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        所有 API 接口都需要 Bearer Token 认证


        获取 API Key：


        进入 **仪表盘 → API 密钥**（[API Key
        管理页面](https://vidgo.ai/apis/dashboard/api-key)）获取你的 API Key


        在请求头中添加：


        ```

        Authorization: Bearer VIDGO_API_KEY

        ```

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.