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

# 创建视频任务

> 提交文生视频任务并立即返回任务 ID，之后查询任务直到完成。按实际生成的输出 tokens 计费（标价每百万 USD 25）：宽 x 高 x (24 x 秒数 + 1) / 1024。提交时按所选分辨率下最大画面和时长再加 10% 预留；任务成功后按实际生成的 tokens 结算，失败、过期或取消的任务不收费。只接受文档列出的字段。



## OpenAPI

````yaml /openapi.cn.json post /api/v3/contents/generations/tasks
openapi: 3.1.0
info:
  title: OmniRelay API
  version: 1.0.0
  description: 面向已核验真实文本模型的兼容 OpenAI 网关。访问按工作空间开通，使用自己的模型列表查询能力与客户价格。
servers:
  - url: https://api.omnirelay.ai
security:
  - bearerAuth: []
tags:
  - name: 服务
  - name: 模型
  - name: 对话
  - name: 管理 API
  - name: 响应
  - name: 向量
  - name: 图片
  - name: 视频
paths:
  /api/v3/contents/generations/tasks:
    post:
      tags:
        - 视频
      summary: 创建视频任务
      description: >-
        提交文生视频任务并立即返回任务 ID，之后查询任务直到完成。按实际生成的输出 tokens 计费（标价每百万 USD 25）：宽 x 高 x
        (24 x 秒数 + 1) / 1024。提交时按所选分辨率下最大画面和时长再加 10% 预留；任务成功后按实际生成的 tokens
        结算，失败、过期或取消的任务不收费。只接受文档列出的字段。
      operationId: createVideoTask
      parameters:
        - name: X-Gateway-Tags
          in: header
          required: false
          description: >-
            本次调用的标签，以逗号分隔的 `key=value`，例如 `client=acme,env=prod`。与 API Key
            的默认标签合并；同名 key 以请求体 `tags` 字段为准。`X-OmniRelay-Tags` 是同一个请求头的旧名，继续接受。
          schema:
            type: string
          example: client=acme,env=prod
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoTaskRequest'
            example:
              model: doubao-seedance-2-0-260128
              content:
                - type: text
                  text: >-
                    A paper boat drifting on a calm pond at sunrise, slow camera
                    pan
              resolution: 480p
              ratio: '16:9'
              duration: 5
      responses:
        '200':
          description: 任务已受理，预留已生效。
          headers:
            X-Request-ID:
              description: OmniRelay 任务 ID，与响应体中的 id 相同。
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTaskCreated'
              example:
                id: 3f0c9a2e-6b1d-4c35-9a7e-2d8c5b1e4f60
        '400':
          description: >-
            invalid_parameter：存在未知字段、多于一个 content 项、非文本项，或取值超出文档范围；error.param
            给出字段名。不发送、不扣费。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_parameter
                request_id: 2f6c1d0e9a
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            inference_budget_or_access_denied 或
            member_budget_exceeded：无法覆盖预留金额。在发送前拒绝。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: inference_budget_or_access_denied
                request_id: 2f6c1d0e9a
        '403':
          description: model_not_allowed：该 API Key 限定只能调用其他模型。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_not_allowed
                request_id: 2f6c1d0e9a
        '404':
          description: model_unavailable：不是本工作区可调用的视频模型。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_unavailable
                request_id: 2f6c1d0e9a
        '413':
          description: payload_too_large：请求体超过 64 KiB。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: payload_too_large
                request_id: 2f6c1d0e9a
        '429':
          description: 触发速率或并发限制。不扣费；请在 Retry-After 秒后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: rate_limited
                request_id: 2f6c1d0e9a
        '502':
          description: >-
            video_submit_held：任务发出后无法确认，转入核对，仅当确实生成了视频时扣费。upstream_rejected：服务方拒绝了任务，不扣费。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: video_submit_held
                request_id: 2f6c1d0e9a
        '503':
          description: 本工作区当前无法使用视频生成。不发送、不扣费。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: live_provider_unavailable
                request_id: 2f6c1d0e9a
        '504':
          description: video_submit_held：提交超时，转入核对，仅当确实生成了视频时扣费。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: video_submit_held
                request_id: 2f6c1d0e9a
components:
  schemas:
    VideoTaskRequest:
      type: object
      required:
        - model
        - content
      additionalProperties: false
      properties:
        model:
          type: string
          description: GET /v1/models 中的视频模型 ID（type 为 video）。
          example: doubao-seedance-2-0-260128
        content:
          type: array
          minItems: 1
          maxItems: 1
          description: 恰好一项文本，1 到 4000 个字符。
          items:
            type: object
            required:
              - type
              - text
            additionalProperties: false
            properties:
              type:
                type: string
                enum:
                  - text
              text:
                type: string
                maxLength: 4000
        resolution:
          type: string
          enum:
            - 480p
            - 720p
          default: 480p
        ratio:
          type: string
          enum:
            - '16:9'
            - '4:3'
            - '1:1'
            - '3:4'
            - '9:16'
            - '21:9'
            - adaptive
          default: '16:9'
        duration:
          type: integer
          minimum: 4
          maximum: 10
          default: 5
          description: 时长，整数秒。
        seed:
          type: integer
          minimum: -1
          maximum: 4294967295
        generate_audio:
          type: boolean
          description: 除非设为 false，视频带音轨。
        watermark:
          type: boolean
        camera_fixed:
          type: boolean
    VideoTaskCreated:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          description: 任务 ID。用 GET /api/v3/contents/generations/tasks/{id} 查询。
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            code:
              type: string
              example: model_unavailable
            message:
              type: string
              example: The model does not exist or is disabled.
              description: 用于日志和 SDK 异常的简短英文说明；措辞可能调整，请按 code 判断。
            type:
              type: string
              example: not_found_error
              description: >-
                按 HTTP
                状态划分的错误类别：invalid_request_error、authentication_error、insufficient_quota、permission_error、not_found_error、conflict_error、rate_limit_error、service_unavailable
                或 api_error。
            param:
              type: string
              maxLength: 200
              description: 可识别时返回被拒绝的请求字段路径，不包含参数值；Responses 使用原生字段名。
        request_id:
          type: string
          description: 在对话补全、Responses 和 Embeddings 出错时返回。
  responses:
    Unauthorized:
      description: '`unauthorized`：缺少 API Key，或该 Key 已吊销或无效。'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。

````

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