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

# Gemini Omni Flash Preview

> Google gemini-omni-flash-preview 文生视频 / 图生视频

## 简介

通过 Gravitex API 调用 Google `gemini-omni-flash-preview` 视频生成模型。支持文生视频、单图图生视频，输出含音频的视频；任务为异步提交 + 轮询。另提供 Google Interactions 原生格式兼容路由。

| 能力          | 支持 | 说明                                        |
| ----------- | -- | ----------------------------------------- |
| 文生视频        | ✅  | `prompt` / `input` 传文本，内部 `text_to_video` |
| 图生视频        | ✅  | 文本 + 单张 Base64 图片，内部 `image_to_video`     |
| 视频输出        | ✅  | 返回最终视频地址（含音频）                             |
| 异步任务        | ✅  | 提交后 GET 轮询                                |
| 同步阻塞 / SSE  | ❌  | 不支持                                       |
| 视频编辑 / 多图参考 | ❌  | 不支持                                       |

## 认证

<ParamField header="Authorization" type="string" required>
  Bearer Token，如 `Bearer sk-xxxxxxxxxxxxxxxx`
</ParamField>

Base URL：`https://api.gravitex.ai`

## 模型与接口总览

| 模型 ID                       | 类型                        | 文生视频 | 图生视频 | 输出      | 任务方式      |
| --------------------------- | ------------------------- | ---- | ---- | ------- | --------- |
| `gemini-omni-flash-preview` | Gemini Omni Flash Preview | ✅    | ✅ 单图 | 视频（含音频） | 异步提交 + 轮询 |

| 接口                                      | 方法   | 用途                         |
| --------------------------------------- | ---- | -------------------------- |
| `/v1/video/generations`                 | POST | 平台视频格式提交任务                 |
| `/v1/video/generations/{task_id}`       | GET  | 平台视频格式查询任务                 |
| `/v1beta/interactions`                  | POST | Google Interactions 格式提交任务 |
| `/v1beta/interactions/{interaction_id}` | GET  | Google Interactions 格式查询任务 |

<Note>
  `/v1beta` 兼容接口最终仍走平台视频任务管线，不会改变其他模型的路由行为。
</Note>

## 平台视频接口

### 提交视频任务

```http theme={null}
POST https://api.gravitex.ai/v1/video/generations
```

```json theme={null}
{
  "model": "gemini-omni-flash-preview",
  "prompt": "生成一只正在草地上吃草的小羊",
  "width": 1280,
  "height": 720,
  "duration": 3,
  "seed": -1,
  "metadata": {
    "seconds": 3,
    "resolution": "720p",
    "aspectRatio": "16:9",
    "durationSeconds": 3,
    "watermark": false,
    "camera_fixed": false
  }
}
```

`prompt` 为必填。Gemini Omni 主要使用以下字段：

| 字段                         | 类型     | 说明                              |
| -------------------------- | ------ | ------------------------------- |
| `model`                    | string | 固定为 `gemini-omni-flash-preview` |
| `prompt`                   | string | 文本提示词，必填                        |
| `metadata.resolution`      | string | 当前推荐 `720p`                     |
| `metadata.aspectRatio`     | string | `16:9` 或 `9:16`                 |
| `metadata.durationSeconds` | number | 建议 3–10 秒，实际受上游限制               |
| `metadata.image`           | string | 图生视频时传图片 Data URL               |

提交成功响应：

```json theme={null}
{
  "code": "success",
  "message": "",
  "data": {
    "id": "video-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "object": "video",
    "model": "gemini-omni-flash-preview",
    "status": "in_progress",
    "progress": 0
  }
}
```

### 轮询任务

```http theme={null}
GET https://api.gravitex.ai/v1/video/generations/{task_id}
```

轮询直到成功或失败：

```json theme={null}
{
  "code": "success",
  "message": "",
  "data": {
    "id": "video-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "object": "video",
    "model": "gemini-omni-flash-preview",
    "status": "completed",
    "progress": 100,
    "url": "https://your-oss-host/video/xxxxxxxx.mp4"
  }
}
```

任务可能处于 `in_progress`。若上游仍在生成，平台保留任务并由后台继续轮询；若上游失败，返回失败原因。不要把 `unknown` 当作最终成功。

统一入口说明亦见 [提交视频任务](/cn/api-reference/endpoint/submit-video-task) 与 [查询视频任务](/cn/api-reference/endpoint/query-video-task)。

## Google Interactions 格式兼容接口

仅改变外部请求/响应形状，内部仍复用平台视频任务、轮询、结果交付与计费链路。

### 提交与查询

```http theme={null}
POST https://api.gravitex.ai/v1beta/interactions
GET  https://api.gravitex.ai/v1beta/interactions/{interaction_id}
```

### 文生视频示例

```bash theme={null}
curl -X POST "https://api.gravitex.ai/v1beta/interactions" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "input": "生成一只正在草地上吃草的小羊",
    "generation_config": {
      "video_config": {
        "task": "text_to_video"
      }
    },
    "response_format": {
      "type": "video",
      "aspect_ratio": "16:9",
      "duration": "3s"
    },
    "background": true
  }'
```

提交返回：

```json theme={null}
{
  "id": "video-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "object": "interaction",
  "model": "gemini-omni-flash-preview",
  "status": "in_progress"
}
```

### 轮询示例

```bash theme={null}
curl "https://api.gravitex.ai/v1beta/interactions/video-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx"
```

完成后：

```json theme={null}
{
  "id": "video-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "object": "interaction",
  "model": "gemini-omni-flash-preview",
  "status": "completed",
  "steps": [
    {
      "type": "video",
      "content": [
        {
          "type": "video",
          "uri": "https://your-oss-host/video/xxxxxxxx.mp4"
        }
      ]
    }
  ]
}
```

## 图生视频

兼容路由支持 `input` 数组中的文本与单张图片 Data URL：

```json theme={null}
{
  "model": "gemini-omni-flash-preview",
  "input": [
    {
      "type": "text",
      "text": "让这张图片中的小羊在草地上慢慢走动"
    },
    {
      "type": "image",
      "mime_type": "image/png",
      "data": "iVBORw0KGgoAAAANSUhEUg..."
    }
  ],
  "generation_config": {
    "video_config": {
      "task": "image_to_video"
    }
  },
  "response_format": {
    "type": "video",
    "aspect_ratio": "16:9",
    "duration": "3s"
  },
  "background": true
}
```

平台会将图片转为内部视频任务输入，并沿用现有渠道选择、任务持久化与结果交付。当前兼容适配器**不会**把 `image.uri` 直接转为图片输入；需要图片时请传 `data`。

平台视频接口也可通过 `metadata.image`（Data URL）做图生视频。

## 响应与轮询

平台接口与原生兼容接口均为异步：提交只返回任务 ID 与进行中状态；客户端按 ID 轮询直至完成或失败。

状态映射：

| 平台任务状态                      | 原生兼容状态        | 说明         |
| --------------------------- | ------------- | ---------- |
| `NOT_START` / `IN_PROGRESS` | `in_progress` | 继续轮询       |
| `SUCCESS`                   | `completed`   | 可读视频地址     |
| `FAILURE`                   | `failed`      | 读错误信息并结束轮询 |

## 计费与用量

Google 官方 Gemini Omni 价格：输入 $1.50 / 1M tokens，文本输出（回答与推理）$9 / 1M tokens，视频输出 $0.10 / 秒；官方同时给出 720p、含音频视频输出按 $17.50 / 1M 视频输出 tokens 的等价口径。[官方价格页](https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/pricing#gemini-omni)

| 上游字段                                              | 平台含义          | 平台计费              |
| ------------------------------------------------- | ------------- | ----------------- |
| `total_input_tokens` 或 `input_tokens_by_modality` | 输入 token      | 输入 \$1.50 / 1M    |
| `total_thought_tokens`、文本输出模态                     | 文本回答与推理 token | 文本输出 \$9 / 1M     |
| `output_tokens_by_modality[modality=video]`       | 视频输出 token    | 视频输出 \$17.50 / 1M |
| `total_tokens`                                    | 上游总用量记录       | 用于审计，不直接替代三类计费拆分  |
