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

# 创建 Gemini Omni 视频任务

> 创建 Gemini Omni 异步文生/图生视频任务。受理后立即返回任务 ID，视频生成结果通过查询接口获取。
`gemini-omni-flash-preview` 支持纯文本生成；如需参考图，可通过 `images` 传入公网可访问图片 URL。


提交 Gemini Omni 异步视频生成任务。平台受理后立即返回任务 ID，视频生成结果通过 [查询 Gemini Omni 视频任务](/api/videos/google-omni-query-task) 接口获取。

```
POST /v1/google-omni/videos/generations
Authorization: Bearer <API_KEY>
Content-Type: application/json
```

***

## 请求参数

| 参数         | 类型               | 必填    | 说明                                                                   |
| ---------- | ---------------- | ----- | -------------------------------------------------------------------- |
| `model`    | string           | **是** | 固定使用 `gemini-omni-flash-preview`，或使用平台返回的可用模型名称。                     |
| `prompt`   | string           | **是** | 视频提示词，描述主体、动作、环境、镜头、风格等。                                             |
| `duration` | integer/string   | 否     | 视频时长（秒）。未传默认 `10`，当前单次最大 `10`。                                       |
| `size`     | string           | 否     | 视频尺寸，格式为 `宽x高`，例如 `1280x720`、`720x1280`、`1920x1080`。未传默认 `1280x720`。 |
| `images`   | string\[]/string | 否     | 参考图 URL。可传数组，也可传英文逗号分隔字符串；最多 7 个公网可访问图片 URL。                         |
| `video`    | string           | 否     | 参考视频 URL。必须是公网可访问 URL。                                               |

<Note>
  Gemini Omni 支持纯文本生成视频，`images` 不是必填。若需要参考图，请传公网可访问 URL；不要传本地文件路径、`data:image/...;base64` 或需要登录的临时 URL。
</Note>

***

## 示例

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST "https://{your-domain}/v1/google-omni/videos/generations" \
    -H "Authorization: Bearer $API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gemini-omni-flash-preview",
      "prompt": "哥斯拉在未来感城市夜景中和一只巨大的怪兽激烈战斗，电影级镜头，低角度仰拍，雨夜霓虹，爆炸火光，震撼但画面帅气，动作流畅，高质量科幻怪兽电影风格",
      "duration": 10,
      "size": "1280x720"
    }'
  ```

  ```python Python theme={null}
  import requests

  resp = requests.post(
      "https://{your-domain}/v1/google-omni/videos/generations",
      headers={
          "Authorization": f"Bearer {API_KEY}",
          "Content-Type": "application/json",
      },
      json={
          "model": "gemini-omni-flash-preview",
          "prompt": "哥斯拉在未来感城市夜景中和一只巨大的怪兽激烈战斗，电影级镜头，低角度仰拍，雨夜霓虹，爆炸火光，震撼但画面帅气",
          "duration": 10,
          "size": "1280x720",
      },
  )
  print(resp.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://{your-domain}/v1/google-omni/videos/generations", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "gemini-omni-flash-preview",
      prompt: "哥斯拉在未来感城市夜景中和一只巨大的怪兽激烈战斗，电影级镜头，低角度仰拍，雨夜霓虹，爆炸火光，震撼但画面帅气",
      duration: 10,
      size: "1280x720",
    }),
  });

  console.log(await response.json());
  ```
</CodeGroup>

***

## 带参考图

```json theme={null}
{
  "model": "gemini-omni-flash-preview",
  "prompt": "参考图片中的角色，在未来城市中做电影感运镜",
  "duration": 10,
  "size": "1280x720",
  "images": [
    "https://example.com/reference-1.jpg",
    "https://example.com/reference-2.jpg"
  ]
}
```

***

## 响应示例

```json theme={null}
{
  "id": "vidtask_a52be4ce35e9466a83004b066f47aa67",
  "object": "video.generation.task",
  "created": 1784300712,
  "model": "gemini-omni-flash-preview",
  "status": "queued",
  "expires_at": 1784473512
}
```

保存响应中的 `id`，然后调用查询接口轮询任务状态。

***

## 计费说明

Gemini Omni 视频按视频秒数计费：

| 字段                | 说明                          |
| ----------------- | --------------------------- |
| `billing_unit`    | `video_second`              |
| `requested_units` | 请求的 `duration` 秒数           |
| `billable_units`  | 任务成功后实际结算秒数，通常等于 `duration` |

任务失败、取消或超时后，平台会退款到对应 API Key 余额。

***

## 常见错误

| 场景                  | 可能错误                                                 | 处理方式                     |
| ------------------- | ---------------------------------------------------- | ------------------------ |
| `prompt` 为空         | `prompt is required`                                 | 传入明确的视频提示词。              |
| `size` 格式错误         | `size must use widthxheight format`                  | 使用 `1280x720` 这类宽高格式。    |
| `duration` 超过上限     | `duration exceeds max_billable_units_per_request 10` | 将 `duration` 调整到 10 秒以内。 |
| 图片 URL 需要登录、过期或被防盗链 | `image_download_error` / HTTP 403                    | 换成可匿名下载的图片直链。            |
| 模型服务额度不足            | `permission-denied` / credits / spending limit       | 联系平台处理额度。                |
| 模型未授权               | `model_not_allowed` / `model_not_visible`            | 检查 API Key 可用模型和域名可见性。   |


## OpenAPI

````yaml POST /v1/google-omni/videos/generations
openapi: 3.1.0
info:
  title: WengaoCloud AI Gateway API
  version: 0.1.0
  description: WengaoCloud AI 聚合平台公开 API 契约草案，覆盖 OpenAI 兼容接口、Anthropic 原生接口和平台扩展接口。
servers:
  - url: https://xxx.wengaocloud.com
    description: 问高云 API 网关根域名。OpenAI SDK 的 base_url 使用 https://xxx.wengaocloud.com/v1。
  - url: https://{tenant}.wengaocloud.com
    description: 控制台展示的租户或 OEM API 网关根域名。
    variables:
      tenant:
        default: xxx
security:
  - bearerAuth: []
tags:
  - name: models
    x-group: 模型
  - name: openai-compatible
    x-group: OpenAI 兼容接口
  - name: anthropic-native
    x-group: Anthropic 原生接口
  - name: images-v3
    x-group: 图片（V3 同步）
  - name: volcengine-images
    x-group: 图片（火山直连）
  - name: images
    x-group: 图片（V1 兼容）
  - name: async-images
    x-group: 图片异步任务
  - name: aliwan-images
    x-group: 图片（百炼万相）
  - name: videos
    x-group: 视频
paths:
  /v1/google-omni/videos/generations:
    post:
      tags:
        - videos
      summary: 创建 Gemini Omni 视频任务
      description: |
        创建 Gemini Omni 异步文生/图生视频任务。受理后立即返回任务 ID，视频生成结果通过查询接口获取。
        `gemini-omni-flash-preview` 支持纯文本生成；如需参考图，可通过 `images` 传入公网可访问图片 URL。
      operationId: createGoogleOmniVideoGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GoogleOmniVideoGenerationRequest'
            examples:
              textToVideo:
                summary: 文生视频
                value:
                  model: gemini-omni-flash-preview
                  prompt: 哥斯拉在未来感城市夜景中和一只巨大的怪兽激烈战斗，电影级镜头，低角度仰拍，雨夜霓虹，爆炸火光，震撼但画面帅气
                  duration: 10
                  size: 1280x720
              imageToVideo:
                summary: 带参考图
                value:
                  model: gemini-omni-flash-preview
                  prompt: 参考图片中的角色，在未来城市中做电影感运镜
                  duration: 10
                  size: 1280x720
                  images:
                    - https://example.com/reference-1.jpg
      responses:
        '202':
          description: 任务已受理并进入队列。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationCreateResponse'
              examples:
                queued:
                  value:
                    id: vidtask_a52be4ce35e9466a83004b066f47aa67
                    object: video.generation.task
                    created: 1784300712
                    model: gemini-omni-flash-preview
                    status: queued
                    expires_at: 1784473512
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientQuota'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    GoogleOmniVideoGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: 平台开通的 Gemini Omni 视频模型名称。
          example: gemini-omni-flash-preview
        prompt:
          type: string
          description: 视频提示词，描述主体、动作、环境、镜头、风格等。
          example: 哥斯拉在未来感城市夜景中和一只巨大的怪兽激烈战斗，电影级镜头，低角度仰拍，雨夜霓虹，爆炸火光，震撼但画面帅气
        duration:
          oneOf:
            - type: integer
            - type: string
          description: 视频时长（秒）。未传默认 10，当前单次最大 10。
          example: 10
        size:
          type: string
          description: 视频尺寸，格式为 `宽x高`，例如 `1280x720`、`720x1280`、`1920x1080`。未传默认 `1280x720`。
          example: 1280x720
        images:
          oneOf:
            - type: array
              items:
                type: string
            - type: string
          description: |
            参考图 URL。可传数组，也可传英文逗号分隔字符串；最多 7 个公网可访问图片 URL。
            Gemini Omni 支持纯文本生成，`images` 不是必填。
          example:
            - https://example.com/reference-1.jpg
        video:
          type: string
          description: 参考视频 URL。必须是公网可访问 URL。
          example: https://example.com/reference.mp4
      additionalProperties: true
    VideoGenerationCreateResponse:
      type: object
      required:
        - id
        - object
        - created
        - model
        - status
      properties:
        id:
          type: string
          description: 平台任务 ID，用于查询任务。
          example: vidtask_3cb6299b32d24f93a82e8a74b3e06161
        object:
          type: string
          enum:
            - video.generation.task
        created:
          type: integer
          description: 任务创建时间，Unix 秒。
        model:
          type: string
          description: 请求中的平台模型名称。
        status:
          type: string
          enum:
            - queued
          description: 初始状态，通常为 `queued`。
        expires_at:
          type: integer
          description: 任务过期时间估算，Unix 秒。
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              example: invalid_request_error
            code:
              type: string
              example: model_endpoint_mismatch
            message:
              type: string
              example: 该模型不支持当前 endpoint。
  responses:
    BadRequest:
      description: 请求参数无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: API Key 缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InsufficientQuota:
      description: 余额或额度不足。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: 模型不可见、API Key 无权限或档位不可用。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      x-default: sk-your-api-key

````