> ## 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` 進行 Webhook 傳遞。建議使用回呼模式來產生影片。

**callback\_url** `string`

當 `request_type` 為 `callback` 時必填。請提供可從網際網路存取的 HTTPS 網址，以接收任務的最終結果。詳見 [Webhook](https://apixo.ai/docs/zh-hant/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` 不會消耗此配額。

## 官方基礎語音選項

呼叫 `gemini-omni-audio` 時必須提供 `voice_key`，請選擇其中一個官方基礎語音。

| 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`

包含產生影片 URL 的 JSON 字串。當影片 `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-hant/api-reference/webhooks.md)。

## 計費

新提交的非 LLM 請求按 **1 點 = `$0.001`** 計費。先依用量和加購項目計算總額，再套用帳戶折扣，最後將請求總額無條件進位至整數點數。若已約定固定單價，則保留該單價的精度，不再使用標準價或另行打折；最終點數仍須進位。詳見[積分換算與進位](https://apixo.ai/docs/zh-hant/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]
>
> 對於生產影片工作負載，請使用回呼模式以避免頻繁輪詢。

音訊和角色模式共享免費資產生成限制 1000 每個用戶的請求數 60 秒。影片模式單獨計費，不消耗此免費資源限額。

請求頻率與並行數上限會依帳戶、API 金鑰和路由而異。收到 `429` 時，請降低請求頻率，並逐步拉長重試間隔。帳戶層級的限制請見[系統 API](https://apixo.ai/docs/zh-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體無效、缺少參數、模式不受支援、值不受支援或超出媒體配額 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `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-hant/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-hant/models.md)
* [影片模型](https://apixo.ai/docs/zh-hant/models/video)
* [送出生成任務](https://apixo.ai/docs/zh-hant/api-reference/generate-task.md)
* [查詢任務狀態](https://apixo.ai/docs/zh-hant/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)
* [錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)
* [參數規範](https://apixo.ai/docs/zh-hant/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh-hant/concepts/routing-strategies.md)
* [嘗試 Gemini Omni 在 APIXO Playground](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.