> ## 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/vidu-q4-preview.json post /v1/videos
openapi: 3.1.0
info:
  description: >-
    Vidu Q4 Preview：首帧图生视频与参考生视频（1 ~ 15 张参考图、0 ~ 3 段参考音频），3 ~ 16 秒，540P 到
    4K，音画同出。
  title: Vidu Q4 Preview
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Vidu Q4 Preview
paths:
  /v1/videos:
    post:
      tags:
        - Vidu Q4 Preview
      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: '`image_url` 传一张首帧图片，输出比例跟随图片。'
                summary: 图生视频（首帧）
                value:
                  model: viduq4
                  input:
                    prompt: 女孩微笑着抚摸狐狸，微风，电影感
                    image_url: https://your-cdn.example.com/first-frame.png
                    resolution: 1080P
                    duration: 5
              参考生视频:
                description: 传 1 ~ 15 张参考图并写提示词，用 `aspect_ratio` 指定宽高比。
                summary: 参考生视频
                value:
                  model: viduq4
                  input:
                    prompt: 女孩和狐狸夜晚坐在篝火旁，镜头在两者之间切换
                    reference_image_urls:
                      - https://your-cdn.example.com/girl.png
                      - https://your-cdn.example.com/fox.png
                    resolution: 720P
                    duration: 8
                    aspect_ratio: '9:16'
              参考生视频 + 参考音频:
                description: 在参考图之外再传 0 ~ 3 段参考音频（mp3，单段 3 ~ 12 秒）。
                summary: 参考生视频 + 参考音频
                value:
                  model: viduq4
                  input:
                    prompt: 女孩对着狐狸说话，声音参考音频，狐狸歪头回应
                    reference_image_urls:
                      - https://your-cdn.example.com/girl.png
                      - https://your-cdn.example.com/fox.png
                    reference_audio_urls:
                      - https://your-cdn.example.com/voice.mp3
                    resolution: 720P
                    duration: 5
                    aspect_ratio: '16:9'
              无声视频与生成选项:
                description: >-
                  `generate_audio: false` 生成无声视频；`enhance_prompt`
                  让模型优化提示词；`seed` 固定随机种子。
                summary: 无声视频与生成选项
                value:
                  model: viduq4
                  input:
                    prompt: 狐狸在雪地里奔跑，镜头跟随
                    image_url: https://your-cdn.example.com/first-frame.png
                    resolution: 540P
                    duration: 3
                    generate_audio: false
                    enhance_prompt: true
                    seed: 20261116
            schema:
              $ref: '#/components/schemas/ViduQ4VideoRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                example:
                  value:
                    task_id: job_02b88886c4fda5be35baff61
                    status: in_progress
                    model: viduq4
                    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:
    ViduQ4VideoRequest:
      additionalProperties: false
      description: 创建 Vidu Q4 Preview 视频生成任务的请求体。
      properties:
        model:
          description: |-
            模型名称，固定为 `viduq4`。

            **可选值：**
            - `viduq4`：Vidu Q4 Preview。
          enum:
            - viduq4
          type: string
        input:
          $ref: '#/components/schemas/ViduQ4VideoInput'
          description: >-
            生成参数。传 `image_url` 为图生视频；传 `reference_image_urls`
            为参考生视频，两者只能二选一。不支持文生视频和首尾帧。
      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
    ViduQ4VideoInput:
      additionalProperties: false
      description: Vidu Q4 Preview 的生成参数。
      properties:
        prompt:
          description: 提示词，描述视频的内容、动作和镜头。参考生视频时必填。
          type: string
        image_url:
          description: >-
            首帧图片的公网 URL（仅一张），传入后为图生视频，不能与 `reference_image_urls` 同时使用。支持 jpeg /
            jpg / png，不超过 10MB。
          type: string
        reference_image_urls:
          description: >-
            参考图片的公网 URL 列表，1 ~ 15 张，传入后为参考生视频，不能与 `image_url` 同时使用。支持 png / jpeg
            / jpg / webp。
          items:
            type: string
          maxItems: 15
          minItems: 1
          type: array
        reference_audio_urls:
          description: >-
            参考音频的公网 URL 列表，0 ~ 3 段，只能与 `reference_image_urls` 一起使用。支持 mp3，单段 3 ~
            12 秒。
          items:
            type: string
          maxItems: 3
          type: array
        resolution:
          default: 720P
          description: |-
            输出分辨率，默认 `720P`。

            **可选值：**
            - `540P`：540P。
            - `720P`：720P。
            - `1080P`：1080P。
            - `2K`：2K。
            - `4K`：4K。
          enum:
            - 540P
            - 720P
            - 1080P
            - 2K
            - 4K
          type: string
        duration:
          default: 5
          description: 输出视频时长，单位秒，`3` ~ `16` 的整数，默认 `5`。
          format: int64
          maximum: 16
          minimum: 3
          type: integer
        aspect_ratio:
          description: |-
            输出宽高比，仅参考生视频有效。传入首帧图片时输出比例跟随图片。

            **可选值：**
            - `16:9`：横屏。
            - `9:16`：竖屏。
            - `1:1`：方形。
            - `4:3`：横屏 4:3。
            - `3:4`：竖屏 3:4。
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '4:3'
            - '3:4'
          type: string
        generate_audio:
          description: 是否音画同出：同步生成带对白和音效的声音，默认开启。传 `false` 生成无声视频。
          type: boolean
        enhance_prompt:
          description: 是否由模型自动优化提示词。
          type: boolean
        seed:
          description: 随机种子，整数；不传则随机。
          format: int64
          type: integer
      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.