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

# Gemini Omni API：Google 多模态视频生成模型

> Google 多模态生成 API，支持音频资产、角色资产和视频生成

## 概览

Gemini Omni 是 Google 在 APIXO 上提供的多模态模型。可使用它创建可复用的音频资产，从图像生成角色资产，并通过文本、图像、视频、音频及角色参考生成视频。

| 功能 | 值 |
| - | - |
| 模型 ID | `gemini-omni` |
| 模式 | `gemini-omni-audio`, `gemini-omni-character`, `gemini-omni-video` |
| 音频资源输出 | `audioId` |
| 角色资产输出 | `characterId` |
| 视频分辨率 | `720p`, `1080p`, `4k` |
| 无视频输入时的视频时长 | `4`、`6`、`8`、`10` 秒 |
| 视频宽高比 | `16:9`, `9:16` |
| 输出 | 音频/角色模式的资源 ID，视频模式的 `resultJson.resultUrls` 中的视频 URL |

## 工作流程

1. 使用 `mode: "gemini-omni-audio"` 创建音频资源并保存返回的 `audioId`。
2. 使用 `mode: "gemini-omni-character"` 创建角色资源并保存返回的 `characterId`。
3. 使用 `mode: "gemini-omni-video"` 生成视频，并可选择传递 `audio_ids`、`character_ids`、`image_urls` 或 `video_urls`。

音频和角色模式在成功时直接返回最终结果。视频模式先返回 `taskId`，之后可轮询结果，也可通过 Webhook 接收。

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/gemini-omni` | 提交音频、字符或视频任务 |
| `GET` | `/statusTask/gemini-omni?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

```http theme={null}
Content-Type: application/json
```

## 异步请求示例

此最小请求提交视频任务并返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/gemini-omni" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "gemini-omni-video",
      "prompt": "a cinematic character walking through a neon street at night",
      "resolution": "1080p",
      "duration": "6",
      "aspect_ratio": "16:9"
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

保存 `taskId`；您需要它来轮询最终的视频结果。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/gemini-omni?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965730929,
    "costTime": 120000
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 请求体

### 音频资源

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "gemini-omni-audio",
    "voice_key": "achernar",
    "name": "demo voice",
    "prompt": "warm, calm narrator",
    "preview_text": "Welcome to the demo."
  }
}
```

### 角色资产

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "gemini-omni-character",
    "prompt": "a friendly studio presenter",
    "name": "studio presenter",
    "image_urls": [
      "https://example.com/character.png"
    ],
    "audio_ids": [
      "audio_123"
    ]
  }
}
```

### 没有视频输入的视频

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "gemini-omni-video",
    "prompt": "a cinematic character walking through a neon street at night",
    "resolution": "1080p",
    "duration": "6",
    "aspect_ratio": "16:9",
    "character_ids": [
      "character_123"
    ],
    "audio_ids": [
      "audio_123",
      "audio_456",
      "audio_789"
    ]
  }
}
```

### 带视频输入的视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "gemini-omni-video",
    "prompt": "replace the room with a neon stage",
    "resolution": "4k",
    "video_urls": [
      "https://example.com/source.mp4"
    ],
    "video_start": 0,
    "video_end": 10
  }
}
```

## 参数

**request\_type** `string` *required* (default: async)

结果交付方式。使用 `async` 进行轮询 `statusTask`，或使用 `callback` 实现回调通知。推荐在生产环境的视频生成中使用回调模式。

**callback\_url** `string`

当 `request_type` 为 `callback` 时必填。请提供公网可访问的 HTTPS 地址，用于接收任务的最终结果。详见 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

Gemini Omni 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `gemini-omni-audio`、`gemini-omni-character`、`gemini-omni-video`。

**prompt** `string`

提示文字。`gemini-omni-character` 和 `gemini-omni-video` 必需提供。`gemini-omni-audio` 可提供可选的语音描述。最大长度为 20000 个字符。

**voice\_key** `string`

`gemini-omni-audio` 所需参数。用于创建音频资产的官方基础语音密钥。无默认值。

**name** `string`

`gemini-omni-audio` 所需参数。`gemini-omni-character` 的可选显示名称。

**preview\_text** `string`

`gemini-omni-audio` 的可选预览对话。

**image\_urls** `string[]`

可公开访问的图像 URL。`gemini-omni-character` 需提供恰好 1 张图像。`gemini-omni-video` 可提供参考图像。

**audio\_ids** `string[]`

`gemini-omni-audio` 返回的可选音频资产 ID。角色请求最多支持 1 个 ID，视频请求最多支持 3 个 ID。

**character\_ids** `string[]`

`gemini-omni-character` 返回的可选角色资产 ID。视频请求最多支持 3 个 ID。

**video\_urls** `string[]`

`gemini-omni-video` 可选视频输入。最多支持 1 个公共视频 URL。

**resolution** `string`

`gemini-omni-video` 必填项。支持的值：`720p`、`1080p`、`4k`。数字别名 `720` 和 `1080` 被接受并标准化。

**duration** `string | integer`

`gemini-omni-video` 必填项，当未提供 `video_urls` 时。支持的值：`4`、`6`、`8`、`10`。当提供 `video_urls` 时将被忽略。

**aspect\_ratio** `string`

`gemini-omni-video` 的可选输出纵横比。支持的值：`16:9`、`9:16`。

**video\_start** `integer`

视频输入的可选起始位置。需要 `video_urls`，且不能为负数。

**video\_end** `integer`

视频输入的可选结束位置。需要 `video_urls`，不能为负数，并且当两者均提供时必须大于或等于 `video_start`。

**seed** `integer`

用于视频生成的可选非负随机种子。

> [!WARNING]
>
> 对于视频模式，`image_urls`、`video_urls` 和 `character_ids` 的多模态配额总量不能超过 7 个单位。每张图像消耗 1 个单位，每个字符 ID 消耗 1 个单位，一个视频 URL 消耗 2 个单位。`audio_ids` 不消耗该配额。

## 官方基础语音选项

`voice_key` 需要用于 `gemini-omni-audio`，请选择一个官方基础语音。

| voice\_key | 语音描述 |
| - | - |
| `achernar` | 女声，柔和，高音调 |
| `achird` | 男声，友善，中音调 |
| `algenib` | 男声，沙哑，低音调 |
| `algieba` | 男声，随和，中低音调 |
| `alnilam` | 男声，坚定，中低音调 |
| `aoede` | 女，轻快，中音 |
| `autonoe` | 女性，明亮，中音 |
| `callirrhoe` | 女性，随和，中音 |
| `charon` | 男性，信息丰富，音调较低 |
| `despina` | 女性，平滑，中音 |
| `enceladus` | 男性，呼吸声，低音调 |
| `erinome` | 女声，清晰，中音 |
| `fenrir` | 男性、易激动、年轻化 |
| `gacrux` | 女性，成熟，中音 |
| `iapetus` | 男声，清晰，中低音 |
| `kore` | 女声，坚定，中音 |
| `laomedeia` | 女声，乐观，中高音 |
| `leda` | 女声，青春，中高音 |
| `orus` | 男声，坚定，中低音调 |
| `puck` | 男声，乐观，中音 |
| `pulcherrima` | 无性别，前倾，中高音 |
| `rasalgethi` | 男声，信息丰富，中音 |
| `sadachbia` | 男声，活泼，低音 |
| `sadaltager` | 男声，知识渊博，中音 |
| `schedar` | 男性，均匀，中低音 |
| `sulafat` | 女声、温暖、中音 |
| `umbriel` | 男声，平滑，低音 |
| `vindemiatrix` | 女声，温柔，中音 |
| `zephyr` | 女声、明亮、中高音 |
| `zubenelgenubi` | 男声，休闲，中低音 |

## 响应格式

### 音频资产响应

音频模式直接返回最终成功结果：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "audioId": "audio_123",
    "name": "demo voice",
    "createTime": 1767965610929,
    "completeTime": 1767965614929,
    "costTime": 4000
  }
}
```

保存 `audioId`。创建角色或生成视频时，将其填入 `audio_ids`。

### 角色资产响应

角色模式直接返回最终成功结果：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "characterId": "character_123",
    "characterName": "studio presenter",
    "imageUrl": "https://file.apixo.ai/character.png",
    "createTime": 1767965610929,
    "completeTime": 1767965620929,
    "costTime": 10000
  }
}
```

保存`characterId`；稍后在 `character_ids` 中使用它来处理视频请求。

### 提交任务时的响应

当接受视频任务时，`POST /generateTask/gemini-omni` 返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`processing_r2`、`success`、`failed`。

**audioId** `string`

音频模式的音频资源 ID。

**name** `string`

音频资产名称。

**characterId** `string`

用于角色模式的角色资源 ID。

**characterName** `string`

角色资产名称。

**imageUrl** `string`

角色图像URL。

**resultJson** `string`

JSON 字符串，包含生成的视频 URL，当视频 `state` 为 `success` 时返回。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理持续时间（单位：毫秒）。在处理成功或失败后返回（如果可用）。

## Webhook 回调模式

当您的后端需要自动接收最终视频结果，而非通过轮询时，请使用回调模式。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/gemini-omni" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "gemini-omni-video",
      "prompt": "a product reveal shot with smooth camera motion and dramatic lighting",
      "resolution": "720p",
      "duration": "4",
      "aspect_ratio": "16:9"
    }
  }'
```

Webhook 接收要求和重试规则见 [Webhook 文档](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

音频和角色资产模式为免费的资产生成模式；视频模式根据是否提供视频输入以及所选的 `resolution` 进行计费。

| 模式 | 条件 | APIXO 价格 |
| - | - | - |
| `gemini-omni-audio` | 每次请求 | `$0.00` |
| `gemini-omni-character` | 每次请求 | `$0.00` |
| `gemini-omni-video` | 无 `video_urls`、`720p` 或 `1080p` | `$0.10 / second` |
| `gemini-omni-video` | 无 `video_urls`、`4k` | `$0.20 / second` |
| `gemini-omni-video` | 提供 `video_urls`、`720p` 或 `1080p` | `$1.20 / request` |
| `gemini-omni-video` | 提供 `video_urls`、`4k` | `$1.80 / request` |

如果没有视频输入，最终视频计费为`resolution unit price * duration`；若有视频输入，则忽略`duration`，按请求固定计费。

最新的美元费率见 [API 价目表](https://apixo.ai/pricing/api)。

## 延迟与轮询

实际延迟可能因提示复杂性、媒体输入、所选路由和当前队列负载而异。

| 工作流程 | 建议首次查询时间 | 轮询间隔 |
| - | - | - |
| 音频资源 | 通常直接返回 | 支持通过 `taskId` 进行可选查询 |
| 角色资产 | 通常直接返回 | 支持通过 `taskId` 进行可选查询 |
| 视频生成 | 任务创建 60 至 90 秒后 | 5-10s |

> [!TIP]
>
> 对于生产环境的视频工作负载，建议使用回调模式以避免频繁轮询。

音频和角色模式共享免费资产生成限制：每用户每 60 秒 1000 次请求。视频模式单独计费，不消耗该免费资源限额。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体无效、缺少参数、模式不支持、值不支持或超出媒体配额 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误 | 逐步延长间隔后重试 |
| `502` | 服务错误 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 对于长时间运行的视频作业，可重试或使用回调模式 |

### 任务失败错误码

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `CONTENT_VIOLATION` | 提示或媒体输入被安全检查拒绝 | 修改提示或输入媒体 |
| `INVALID_INPUT_URL` | 无法访问提供的输入 URL | 使用可公开访问且可直接访问的 URL |
| `UPSTREAM_ERROR` | 服务无法完成任务 | 稍后重试或通过 `taskId` 联系支持人员 |
| `UNKNOWN_ERROR` | 任务因未知原因失败 | 稍后重试或通过 `taskId` 联系支持人员 |

### 常见验证问题

| 问题 | 解决办法 |
| - | - |
| 缺少 `mode` | 设置支持的 Gemini Omni 模式之一 |
| 音频模式下缺少 `voice_key` | 选择一个官方基础语音键 |
| 音频模式下缺少 `name` | 提供非空的显示名称 |
| 角色模式下缺少 `image_urls` | 准确提供 1 个可公开访问的图像 URL |
| 太多`audio_ids` | 对于角色请求最多使用 1 个音频资源 ID，对于视频请求最多使用 3 个音频资源 ID |
| `video_urls`多个 | 最多使用 1 个视频 URL |
| 缺少 `duration`，没有 `video_urls` | 将`duration`设置为`4`、`6`、`8`或`10` |
| `video_start` 或 `video_end` 不带 `video_urls` | 提供 `video_urls` 或删除范围字段 |
| 多式联运配额超过 7 个单位 | 使用更少的图像 URL、视频 URL 或角色 ID |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/gemini-omni.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_urls`, `video_urls`。请保留用户指定的文件顺序。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [视频模型](https://apixo.ai/docs/zh/models/video)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh/concepts/routing-strategies.md)
* [在 APIXO Playground 尝试 Gemini Omni](https://apixo.ai/models/gemini-omni)
* [API定价](https://apixo.ai/pricing/api)


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