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

# 建立 Omni 影片

> 透過 CometAPI 使用 POST /v1/videos 建立 beta 版 Omni 影片任務，接著輪詢任務並下載完成的 MP4 檔案。

使用這個 beta 端點來建立 Omni 影片任務。API 會立即回傳任務 ID，因此請儲存回傳的 `id`，並持續輪詢任務直到其到達最終狀態。

<Badge color="orange" size="sm" shape="pill">Beta</Badge>

`POST /v1/videos` 使用 `multipart/form-data`；請將純量控制項作為表單欄位傳入。

## 選擇輸入模式

| 目標    | 必填欄位              | 選填欄位                                    |
| ----- | ----------------- | --------------------------------------- |
| 文字轉影片 | `model`, `prompt` | `seconds`, `aspect_ratio`, `resolution` |

本頁請使用 `model=omni-fast`。

## 設定時長、比例與解析度

Omni 被標示為 beta，因為生成穩定性可能會因輸入內容與所選路由而有所差異。請先讓第一次請求保持精簡，再檢查完成的影片，之後再決定是否依賴特定的輸出時長或影格尺寸。

| 設定             | 支援值                       | 預設值    | 邊界行為                                   |
| -------------- | ------------------------- | ------ | -------------------------------------- |
| `seconds`      | 從 `4` 開始                  | `4`    | 當此端點仍為 beta 時，請先使用短片段。                 |
| `aspect_ratio` | `16:9`, `9:16`, `1:1`     | `16:9` | `9:16` 可產生直式輸出。`1:1` 可能會被接受，但仍以橫式輸出呈現。 |
| `resolution`   | 從 `720p` 開始；也可能接受 `1080p` | `720p` | 目前實際產出的輸出即使請求 `1080p`，也可能會正規化為 `720p`。 |

| 請求                                      | 觀察到的完成影格尺寸 |
| --------------------------------------- | ---------- |
| `resolution=720p`, `aspect_ratio=16:9`  | `1280x720` |
| `resolution=720p`, `aspect_ratio=9:16`  | `720x1280` |
| `resolution=720p`, `aspect_ratio=1:1`   | `1280x720` |
| `resolution=1080p`, `aspect_ratio=16:9` | `1280x720` |

由於此端點為 beta，請將 `aspect_ratio` 與 `resolution` 視為生成偏好設定，並在依賴最終像素前先驗證下載的 MP4。

## 任務流程

<Steps>
  <Step title="建立任務">
    送出 multipart 表單請求，並儲存回傳的 `id`。
  </Step>

  <Step title="輪詢任務">
    呼叫[擷取 Omni 影片](./retrieve)，直到 `status` 為 `completed` 或 `failed`。
  </Step>

  <Step title="下載結果">
    當任務為 `completed` 時，呼叫[擷取 Omni 影片內容](./retrieve-content)以下載 MP4 檔案。
  </Step>
</Steps>


## OpenAPI

````yaml api/openapi/video/omni/post-create.openapi.json POST /v1/videos
openapi: 3.1.0
info:
  title: Omni Video Create API
  version: 1.0.0
  description: >-
    Create an asynchronous beta Omni video task through CometAPI. Save the
    returned id, poll GET /v1/videos/{task_id}, and download the completed MP4
    file.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/videos:
    post:
      summary: Create an Omni video task
      description: >-
        Create a beta Omni text-to-video task. Send request controls as
        multipart/form-data fields.
      operationId: omni_create_video
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/OmniCreateRequest'
            examples:
              text_to_video:
                summary: Text-to-video
                value:
                  model: omni-fast
                  prompt: Ocean waves rolling onto a sandy beach at golden hour
                  seconds: '4'
                  aspect_ratio: '16:9'
                  resolution: 720p
      responses:
        '200':
          description: >-
            Task accepted. Store the returned id and poll GET
            /v1/videos/{task_id}.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OmniVideoTask'
              example:
                id: task_example
                task_id: task_example
                object: video
                model: omni-fast
                status: queued
                progress: 0
                created_at: 1779938152
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          label: Text-to-video
          source: |-
            curl https://api.cometapi.com/v1/videos \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -F model=omni-fast \
              -F 'prompt=Ocean waves rolling onto a sandy beach at golden hour' \
              -F seconds=4 \
              -F aspect_ratio=16:9 \
              -F resolution=720p
        - lang: Python
          label: Text-to-video
          source: |
            import os
            import requests

            fields = [
                ("model", (None, "omni-fast")),
                ("prompt", (None, "Ocean waves rolling onto a sandy beach at golden hour")),
                ("seconds", (None, "4")),
                ("aspect_ratio", (None, "16:9")),
                ("resolution", (None, "720p")),
            ]

            response = requests.post(
                "https://api.cometapi.com/v1/videos",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                files=fields,
                timeout=120,
            )

            response.raise_for_status()
            print(response.json())
        - lang: JavaScript
          label: Text-to-video
          source: >
            const form = new FormData();

            form.append("model", "omni-fast");

            form.append("prompt", "Ocean waves rolling onto a sandy beach at
            golden hour");

            form.append("seconds", "4");

            form.append("aspect_ratio", "16:9");

            form.append("resolution", "720p");


            const response = await fetch("https://api.cometapi.com/v1/videos", {
              method: "POST",
              headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
              body: form,
            });


            const result = await response.json();

            console.log(result);
components:
  schemas:
    OmniCreateRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: Omni model ID for this endpoint. Use omni-fast for text-to-video.
          enum:
            - omni-fast
          example: omni-fast
        prompt:
          type: string
          description: Text prompt that describes the video to generate.
          example: Ocean waves rolling onto a sandy beach at golden hour
        seconds:
          type: string
          description: >-
            Requested clip duration in seconds. Start with 4 while this endpoint
            is beta.
          default: '4'
          example: '4'
        aspect_ratio:
          type: string
          description: >-
            Output aspect ratio preference. 16:9 and 9:16 are the most
            predictable; 1:1 can be accepted but may render as landscape.
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
          default: '16:9'
          example: '16:9'
        resolution:
          type: string
          description: >-
            Output resolution preference. Start with 720p. 1080p can be accepted
            but current production output may normalize to 720p.
          example: 720p
      additionalProperties: false
    OmniVideoTask:
      type: object
      required:
        - id
        - object
        - model
        - status
        - progress
        - created_at
      properties:
        id:
          type: string
          description: Task ID. Use this value with retrieve and content endpoints.
          example: task_example
        task_id:
          type: string
          description: Compatibility alias for id when present.
          example: task_example
        object:
          type: string
          description: Object type. Video tasks return video.
          example: video
        model:
          type: string
          description: Model ID used for the task.
          example: omni-fast
        status:
          type: string
          description: >-
            Task lifecycle status. Poll until the value is completed, failed, or
            error.
          enum:
            - queued
            - in_progress
            - completed
            - failed
            - error
          example: queued
        progress:
          type: integer
          minimum: 0
          maximum: 100
          description: Task progress as a coarse percentage.
          example: 0
        created_at:
          type: integer
          description: Task creation time as a Unix timestamp in seconds.
          example: 1779938152
        completed_at:
          type: integer
          description: >-
            Task completion time as a Unix timestamp in seconds. This field
            appears on completed tasks.
          example: 1779938219
        video_url:
          type: string
          description: Temporary video delivery URL. This field appears on completed tasks.
          example: <temporary-video-url>
        error:
          type: object
          description: Failure details. This field appears when the task fails.
          properties:
            code:
              type: string
              description: Provider or CometAPI error code.
            message:
              type: string
              description: Human-readable failure reason.
            type:
              type: string
              description: Error category when returned.
          additionalProperties: true
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer authentication. Use your CometAPI API key.

````