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

# 创建视频生成任务

> 提交一个异步视频生成任务并立即返回 `task_id`，视频在后台生成。请求体为 `{"model": "...", "input": {...}}`，所有生成参数都放在 `input` 中。拿到 `task_id` 后用 `GET /v1/videos/{task_id}` 轮询，直到 `status` 为 `completed` 或 `failed`。



## OpenAPI

````yaml /openapi/zh/kling-4-0-omni.json post /v1/videos
openapi: 3.1.0
info:
  description: 可灵 Kling 4.0 Omni：多模态参考生视频与视频编辑，可同时参考最多 10 张图片、5 段视频和 3 段音频。
  title: Kling 4.0 Omni
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Kling 4.0 Omni
paths:
  /v1/videos:
    post:
      tags:
        - Kling 4.0 Omni
      summary: 创建视频生成任务
      description: >-
        提交一个异步视频生成任务并立即返回 `task_id`，视频在后台生成。请求体为 `{"model": "...", "input":
        {...}}`，所有生成参数都放在 `input` 中。拿到 `task_id` 后用 `GET /v1/videos/{task_id}`
        轮询，直到 `status` 为 `completed` 或 `failed`。
      operationId: videoCreateTask
      requestBody:
        content:
          application/json:
            examples:
              多图参考生视频:
                description: 传多张参考图，在提示词中说明每张图的用途。
                summary: 多图参考生视频
                value:
                  model: kling-4.0-omni
                  input:
                    prompt: 第一张图中的女孩和第二张图中的狐狸一起走在雪地森林里，电影感
                    reference_image_urls:
                      - https://your-cdn.example.com/girl.png
                      - https://your-cdn.example.com/fox.png
                    resolution: 1080P
                    duration: 5
                    aspect_ratio: '16:9'
              参考图 + 参考音频:
                description: 参考图加参考音频，21:9 超宽屏输出。
                summary: 参考图 + 参考音频
                value:
                  model: kling-4.0-omni
                  input:
                    prompt: 参考图中的女孩面对镜头说话，声音参考音频，背景是黄昏的海边
                    reference_image_urls:
                      - https://your-cdn.example.com/girl.png
                    reference_audio_urls:
                      - https://your-cdn.example.com/voice.mp3
                    resolution: 720P
                    duration: 5
                    aspect_ratio: '21:9'
              视频特征参考:
                description: >-
                  `reference_video_type` 为
                  `feature`：把视频作为特征参考生成新视频。带参考视频的请求按有参考视频的价格计费。
                summary: 视频特征参考
                value:
                  model: kling-4.0-omni
                  input:
                    prompt: 参考视频中的镜头运动，拍摄一辆红色跑车驶过沙漠公路
                    reference_video_urls:
                      - https://your-cdn.example.com/reference.mp4
                    reference_video_type: feature
                    resolution: 720P
                    duration: 5
              视频编辑:
                description: >-
                  `reference_video_type` 为
                  `base`：在原视频上按提示词修改，`keep_original_sound: true` 保留原声。
                summary: 视频编辑
                value:
                  model: kling-4.0-omni
                  input:
                    prompt: 把视频中的季节从夏天改为下雪的冬天，人物和动作保持不变
                    reference_video_urls:
                      - https://your-cdn.example.com/reference.mp4
                    reference_video_type: base
                    keep_original_sound: true
                    resolution: 720P
                    duration: 5
            schema:
              $ref: '#/components/schemas/Kling40OmniVideoRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                example:
                  value:
                    task_id: job_02b88886c4fda5be35baff61
                    status: in_progress
                    model: kling-4.0-omni
                    created_at: 1794846663
                    request_id: req_6a9a539502118ba1c33f1bfc
              schema:
                $ref: '#/components/schemas/VideoCreateTaskResponse'
          description: 任务已创建。
          headers:
            X-Request-Id:
              description: 本次请求的 ID，排查问题时请提供。
              schema:
                type: string
        '400':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: invalid_request
                      http_status: 400
                      message: Invalid request.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: invalid_request_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: 参数错误：缺少必填参数或取值不合法。数值或数量超出范围时错误信息会指出字段和允许范围；其他情况为通用提示。不创建任务、不扣费。
        '401':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: unauthorized
                      http_status: 401
                      message: Invalid API key.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: authentication_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: API Key 缺失或无效。
        '402':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: insufficient_balance
                      http_status: 402
                      message: Insufficient balance.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: insufficient_balance_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: 余额不足：账户余额低于本次请求的预估价格，不创建任务。
        '429':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: rate_limit_exceeded
                      http_status: 429
                      message: Rate limit exceeded. Please try again later.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: rate_limit_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: 请求过于频繁，请稍后重试。
        '502':
          content:
            application/json:
              examples:
                example:
                  value:
                    error:
                      code: service_unavailable
                      http_status: 502
                      message: Service temporarily unavailable. Please try again later.
                      request_id: req_6a9a539502118ba1c33f1bfc
                      type: api_error
              schema:
                $ref: '#/components/schemas/VideoAPIErrorResponse'
          description: 模型服务暂时不可用，未创建任务、不扣费，可稍后重试。
components:
  schemas:
    Kling40OmniVideoRequest:
      additionalProperties: false
      description: 创建 Kling 4.0 Omni 视频生成任务的请求体。
      properties:
        model:
          description: |-
            模型名称，固定为 `kling-4.0-omni`。

            **可选值：**
            - `kling-4.0-omni`：Kling 4.0 Omni。
          enum:
            - kling-4.0-omni
          type: string
        input:
          $ref: '#/components/schemas/Kling40OmniVideoInput'
          description: 生成参数。`prompt` 必填；参考图片、参考视频和参考音频按需组合。
      required:
        - model
        - input
      type: object
    VideoCreateTaskResponse:
      additionalProperties: false
      description: 创建任务的响应。
      properties:
        task_id:
          description: 任务 Id，用于查询任务。
          type: string
        status:
          description: |-
            任务状态，创建后为 `queued` 或 `in_progress`。

            **可选值：**
            - `queued`：排队中。
            - `in_progress`：生成中。
            - `completed`：生成成功，从 `video_url` 下载视频。
            - `failed`：生成失败，原因见 `error`，不扣费。
          enum:
            - queued
            - in_progress
            - completed
            - failed
          type: string
        model:
          description: 模型名称。
          type: string
        created_at:
          description: 任务创建时间，Unix 秒级时间戳。
          format: int64
          type: integer
        request_id:
          description: 本次请求的 ID，排查问题时请提供。
          type: string
      required:
        - task_id
        - status
        - model
        - created_at
        - request_id
      type: object
    VideoAPIErrorResponse:
      additionalProperties: false
      description: 错误响应。
      properties:
        error:
          $ref: '#/components/schemas/VideoAPIError'
          description: 错误信息。
      required:
        - error
      type: object
    Kling40OmniVideoInput:
      additionalProperties: false
      description: Kling 4.0 Omni 的生成参数。
      properties:
        prompt:
          description: 提示词，必填。描述视频内容，并说明各个参考素材的用途。
          type: string
        reference_image_urls:
          description: 参考图片的公网 URL 列表，最多 10 张。支持 jpeg / jpg / png，单张不超过 10MB。
          items:
            type: string
          maxItems: 10
          type: array
        reference_video_urls:
          description: >-
            参考视频的公网 URL 列表，最多 5 段。支持 mp4 / mov，单段 3 ~ 30 秒，合计不超过 30
            秒。传入参考视频后按有参考视频的价格计费，计费时长为参考视频时长 + 输出时长（参考视频长于输出时）或输出时长 × 2。
          items:
            type: string
          maxItems: 5
          type: array
        reference_video_type:
          description: |-
            参考视频的用法，仅在传入 `reference_video_urls` 时有效。

            **可选值：**
            - `feature`：特征参考视频：参考该视频的特征生成新视频。
            - `base`：待编辑视频：在该视频的基础上按提示词编辑。
          enum:
            - feature
            - base
          type: string
        keep_original_sound:
          description: 是否保留参考视频的原声，仅在传入 `reference_video_urls` 时有效。
          type: boolean
        reference_audio_urls:
          description: 参考音频的公网 URL 列表，最多 3 段，支持 mp3。
          items:
            type: string
          maxItems: 3
          type: array
        resolution:
          default: 720P
          description: |-
            输出分辨率，默认 `720P`。

            **可选值：**
            - `720P`：720P，原生输出。
            - `1080P`：1080P，原生输出。
            - `2K`：2K，超分输出。
            - `4K`：4K，超分输出。
          enum:
            - 720P
            - 1080P
            - 2K
            - 4K
          type: string
        duration:
          default: 5
          description: 输出视频时长，单位秒，`3` ~ `30` 的整数，默认 `5`。
          format: int64
          maximum: 30
          minimum: 3
          type: integer
        aspect_ratio:
          description: |-
            输出宽高比。

            **可选值：**
            - `16:9`：横屏。
            - `9:16`：竖屏。
            - `1:1`：方形。
            - `21:9`：超宽屏。
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '21:9'
          type: string
      required:
        - prompt
      type: object
    VideoAPIError:
      additionalProperties: false
      description: 错误信息。
      properties:
        code:
          description: 错误码。
          type: string
        http_status:
          description: HTTP 状态码。
          format: int64
          type: integer
        message:
          description: 可读的错误说明。
          type: string
        request_id:
          description: 请求 ID，排查问题时请提供。
          type: string
        type:
          description: |-
            错误类型。

            **可选值：**
            - `invalid_request_error`：请求参数错误。
            - `authentication_error`：认证失败。
            - `insufficient_balance_error`：余额不足。
            - `permission_error`：无权限。
            - `rate_limit_error`：请求过于频繁。
            - `api_error`：服务端错误。
          enum:
            - invalid_request_error
            - authentication_error
            - insufficient_balance_error
            - permission_error
            - rate_limit_error
            - api_error
          type: string
      required:
        - code
        - http_status
        - message
        - request_id
        - type
      type: object
  securitySchemes:
    bearerAuth:
      description: 'DreamTo 控制台创建的 API Key，格式 `Authorization: Bearer <API Key>`。'
      scheme: bearer
      type: http

````

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