---
title: "Gemini Omni 视频"
url: "/docs/gemini-omni"
base_url:
  - "https://api.o1key.com"  # 主地址
auth: "Authorization: Bearer <API Key>"
endpoints:
  - "POST /v1/videos"
  - "GET /v1/videos/{task_id}"
  - "GET /v1/videos/{task_id}/content"
---

# Gemini Omni 视频

文生视频、图生视频、多参考图生视频和视频编辑。媒体输入只接受 Base64，完成后通过内容接口下载 MP4。

## Agent 调用规则

1. POST `/v1/videos`，`model` 固定 `gemini-omni-flash-preview`，记录返回的任务 ID。
2. 图片和视频只能用 Base64 或 Data URI，不要传 HTTP URL。
3. 定期 GET `/v1/videos/{task_id}`，`queued` 或 `in_progress` 时继续查询。
4. `completed`：GET `/v1/videos/{task_id}/content` 下载 MP4 交给用户。
5. `failed`：把错误信息告诉用户，不要自动重试。

## 简明说明

### 这个接口做什么？

用 Gemini Omni 生成视频，或编辑一段已有视频。图片和视频必须以 Base64 传入，不接受网址。接口先返回**任务编号**，完成后用内容接口下载视频文件。

### 你需要提供的信息

- **用哪个模型**：`model`，固定 `gemini-omni-flash-preview`。
- **做什么**：`mode`：`text_to_video`、`image_to_video`、`reference_to_video` 或 `edit`。
- **想要什么画面**：`prompt`，文生视频必填。
- **素材（按模式）**：`image`、`images` 或 `video_url`，都用 Base64。

### 怎么拿到结果

- **状态**：`queued`、`in_progress` 继续等待；`completed` 成功；`failed` 失败。
- **视频文件**：`completed` 后 GET `/v1/videos/{task_id}/content`，响应体就是 MP4。

## 创建 Gemini Omni 视频任务

`POST /v1/videos`

固定使用 `gemini-omni-flash-preview`。返回公开任务 ID。

> **媒体输入**：仅接受 Base64 Data URI 或原始 Base64，不接受远程 URL。

### 请求参数

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `model` | string | 是 | 固定为 `gemini-omni-flash-preview`。 |
| `mode` | string | 建议 | `text_to_video`、`image_to_video`、`reference_to_video` 或 `edit`。不传时会根据媒体字段推断。 |
| `prompt` | string | 条件 | 文生视频必填；其余模式可选。 |
| `image` | string | 条件 | 单图生视频使用一张 Base64 图片。推荐写成 `data:image/png;base64,...`。 |
| `images` | string[] | 条件 | 多参考图模式使用，一张或多张 Base64 图片。单图模式最多一张。 |
| `video_url` | string | 条件 | 视频编辑模式必填，使用 `data:video/mp4;base64,...` 或原始 Base64，不接受 HTTP URL。 |
| `duration` | integer | 否 | 兼容字段，允许 3 到 10 的整数；也可使用 `seconds`。若两者同时出现，值必须一致。实际输出长度由模型决定，编辑模式不要传。 |
| `aspect_ratio` | string | 否 | `16:9` 或 `9:16`，默认 `16:9`。编辑模式不要传。 |
| `metadata.thinking_level` | string | 否 | `low` 或 `high`，默认 `low`。 |
| `metadata.thinking_summaries` | string | 否 | `auto` 或 `none`，默认 `auto`。 |

### 模式约束

| `mode` | 输入要求 | 不允许的输入 |
|---|---|---|
| `text_to_video` | 非空 `prompt` | 图片、视频 |
| `image_to_video` | 正好一张图片，可带提示词 | 多张图片、视频 |
| `reference_to_video` | 一张或多张参考图片，可带提示词 | 视频 |
| `edit` | 一个 Base64 视频，可带提示词 | 图片、时长、比例和尺寸参数 |

### 计费说明

系统读取上游返回的输入、文本输出、思考和视频模态 Token 分别结算。720p 视频按每秒 5,792 个视频 Token 计量；最终扣费以上游实际用量为准，不按请求中的预估时长直接结算。

### 请求示例

#### 文生视频

```bash
curl https://api.o1key.com/v1/videos \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "mode": "text_to_video",
    "prompt": "A blue paper boat drifts slowly across calm studio water, fixed camera.",
    "aspect_ratio": "16:9",
    "metadata": {
      "thinking_level": "low",
      "thinking_summaries": "none"
    }
  }'
```

#### 单图生视频

```bash
curl https://api.o1key.com/v1/videos \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "mode": "image_to_video",
    "image": "data:image/png;base64,iVBORw0KGgoAAA...",
    "prompt": "Animate the abstract color field with a slow, smooth wave.",
    "aspect_ratio": "16:9"
  }'
```

#### 多参考图

```bash
curl https://api.o1key.com/v1/videos \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "mode": "reference_to_video",
    "images": [
      "data:image/png;base64,iVBORw0KGgoAAA...",
      "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
    ],
    "prompt": "Create a smooth transition using the colors and shapes from both references.",
    "aspect_ratio": "9:16"
  }'
```

#### 视频编辑

```bash
curl https://api.o1key.com/v1/videos \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-flash-preview",
    "mode": "edit",
    "video_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29t...",
    "prompt": "Keep the motion and add a subtle warm sunset color grade.",
    "metadata": {
      "thinking_level": "low",
      "thinking_summaries": "none"
    }
  }'
```

### 创建响应

```json
{
  "id": "task_omni_xxxxxxxxxx",
  "task_id": "task_omni_xxxxxxxxxx",
  "object": "video",
  "model": "gemini-omni-flash-preview",
  "status": "queued",
  "progress": 10,
  "created_at": 1786680000
}
```

### 参数错误响应

```json
{
  "error": {
    "code": "invalid_duration",
    "message": "duration must be between 3 and 10 seconds",
    "type": "new_api_error"
  }
}
```

## 查询与下载 Gemini Omni 视频

`GET /v1/videos/{task_id}`
`GET /v1/videos/{task_id}/content`

状态：`queued`、`in_progress`、`completed`、`failed`。

`completed` 后调用内容接口下载 MP4。

### 查询状态

```bash
curl https://api.o1key.com/v1/videos/<task_id> \
  -H "Authorization: Bearer $API_KEY"
```

### 完成响应

```json
{
  "id": "task_omni_xxxxxxxxxx",
  "object": "video",
  "model": "gemini-omni-flash-preview",
  "status": "completed",
  "progress": 100,
  "created_at": 1786680000,
  "completed_at": 1786680632
}
```

### 下载视频

```bash
curl https://api.o1key.com/v1/videos/<task_id>/content \
  -H "Authorization: Bearer $API_KEY" \
  --output gemini-omni-result.mp4
```
