# Gemini Omni 文生视频 > 使用 Gemini Omni 从一个文本提示生成带同步音频、对白和音乐的视频。免费试用——按次付费,无需订阅。 ## 概览 - **端点**: `POST https://api.muapi.ai/api/v1/gemini-omni-text-to-video` - **模型 ID**: `gemini-omni-text-to-video` - **类别**: 文生视频 - **变体**: Text to Video - **系列**: gemini-omni - **费用**: 每次调用 1.5 credits(部分模型会根据参数动态计算费用) ## API 使用 MuApi 使用**提交后轮询**模式:提交任务,获取 `request_id`,然后轮询预测端点,直到 `status` 为 `completed`。也可以在提交请求中传入 `?webhook=YOUR_URL`,任务完成后接收 POST 回调(无需轮询)。 **身份验证**:在 `x-api-key` 请求头中发送 MuApi 密钥。可在 https://muapi.ai/access-keys 获取。 ### 1. 提交任务 ```http POST https://api.muapi.ai/api/v1/gemini-omni-text-to-video Content-Type: application/json x-api-key: YOUR_API_KEY ``` **最小请求(仅必填参数):** ```json { "prompt": "" } ``` **完整示例(全部参数):** ```json { "prompt": "", "duration": 8, "resolution": "1080p", "aspect_ratio": "16:9", "audio_ids": [], "seed": 0, "character_ids": [] } ``` **响应:** ```json { "request_id": "abc123", "status": "processing" } ``` ### 2. 轮询结果 ```http GET https://api.muapi.ai/api/v1/predictions/{request_id}/result x-api-key: YOUR_API_KEY ``` 可能的 `status` 值:`queued`、`pending`、`processing`、`completed`、`failed`、`cancelled`。每 2–5 秒轮询一次,直到进入终止状态。状态为 `completed` 时,结果 URL 位于 `outputs` 数组中。 **`completed` 状态的响应示例:** ```json { "id": "abc123", "status": "completed", "outputs": [ "https://cdn.muapi.ai/.../output.png" ], "urls": { "get": "https://api.muapi.ai/api/v1/predictions/abc123/result" }, "created_at": "2026-05-08T12:34:56Z", "has_nsfw_contents": [] } ``` ### cURL ```bash 1. 提交 REQUEST_ID=$(curl -s -X POST https://api.muapi.ai/api/v1/gemini-omni-text-to-video \ -H "x-api-key: $MUAPI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"prompt":""}' | jq -r .request_id) 2. 轮询直到完成 while :; do RESP=$(curl -s https://api.muapi.ai/api/v1/predictions/$REQUEST_ID/result -H "x-api-key: $MUAPI_API_KEY") STATUS=$(echo "$RESP" | jq -r .status) [ "$STATUS" = "completed" ] && echo "$RESP" | jq .outputs && break [ "$STATUS" = "failed" ] && echo "$RESP" && exit 1 sleep 3 done ``` ### Python ```python import os, time, requests API = "https://api.muapi.ai/api/v1" headers = {"x-api-key": os.environ["MUAPI_API_KEY"]} r = requests.post(f"{API}/gemini-omni-text-to-video", headers=headers, json={"prompt":""}) request_id = r.json()["request_id"] while True: res = requests.get(f"{API}/predictions/{request_id}/result", headers=headers).json() if res["status"] == "completed": print(res["outputs"]); break if res["status"] == "failed": raise RuntimeError(res.get("error")); time.sleep(3) ``` ## 输入结构 API 接受以下输入参数: - **`prompt`** (`string`, _必填_): 所需视频内容的文本描述。Gemini Omni 支持丰富的多模态提示词,包括场景构图、镜头指令、对话和环境音频提示。 - **`duration`** (`int`, _可选_): 生成视频的时长(秒)。 - 默认值: `8` - 选项: `"4"`, `"6"`, `"8"`, `"10"` - **`resolution`** (`string`, _可选_): 输出视频分辨率。按输出秒数计费:360p 为 $0.039/秒,720p 为 $0.13/秒,1080p 为 $0.195/秒,4K 为 $0.39/秒。 - 默认值: `"1080p"` - 选项: `"360p"`, `"720p"`, `"1080p"`, `"4k"` - **`aspect_ratio`** (`string`, _可选_): 输出视频的画面比例。 - 默认值: `"16:9"` - 选项: `"16:9"`, `"9:16"` - **`audio_ids`** (`array`, _可选_): 最多 3 voice profile IDs returned by the Gemini Omni Audio endpoint. - **`seed`** (`int`, _可选_): 随机种子(0–2147483647)。固定后可复现结果,但由于模型随机性,结果仍可能有所不同。 - 默认值: `0` - **`character_ids`** (`array`, _可选_): 最多 3 character IDs from Gemini Omni Character to feature in the video. ## 输出结构 轮询端点会返回以下字段: - **`id`** (`string`): 请求 ID。 - **`status`** (`string`): 取值之一:`queued`、`pending`、`processing`、`completed`、`failed`、`cancelled`。 - **`outputs`** (`array`): 生成的图像、视频或音频 URL。`status` 为 `completed` 前为空。 - **`urls.get`** (`string`): 用于重新获取此预测结果的自身链接。 - **`error`** (`string` | `null`): `status` 为 `failed` 时的错误消息。 - **`created_at`** (`string`): 创建请求时的 ISO-8601 时间戳。 - **`has_nsfw_contents`** (`array of boolean`): 每个输出对应的 NSFW 检测标记。 ## Webhook(可选) 在提交 URL 后附加 `?webhook=https://your-server/path`。任务进入终止状态后,MuApi 会将与轮询响应相同结构的 POST 请求发送到你的 URL,无需轮询。 ## Agent 集成 MuApi 提供 MCP 服务器和 CLI,让 Agent(Claude Code、Cursor 或自定义 Agent)无需编写 HTTP 代码即可调用此端点: ```bash # 安装 CLI npm install -g muapi-cli # 完成一次身份验证 muapi auth login # 将所有 MuApi 模型作为 MCP 工具提供给 Agent muapi mcp serve ``` MCP 服务器为每个模型提供封装提交与轮询的工具,包括 `gemini-omni-text-to-video`。使用 `muapi --help` 查看按类别划分的快捷命令(`muapi image generate`、`muapi video from-image` 等)。 ## 相关模型 - [图生视频](https://muapi.ai/zh/playground/gemini-omni-image-to-video) - [Audio Profile](https://muapi.ai/zh/playground/gemini-omni-audio) - [Character Creation](https://muapi.ai/zh/playground/gemini-omni-character) - [1.1 Flash](https://muapi.ai/zh/playground/gemini-omni-flash-1-1-text-to-video) - [文生视频](https://muapi.ai/zh/playground/gemini-omni-text-to-video) - [Video Edit](https://muapi.ai/zh/playground/gemini-omni-video-edit) - [1.1 Flash Image to Video](https://muapi.ai/zh/playground/gemini-omni-flash-1-1-image-to-video) - [1.1 Flash Edit](https://muapi.ai/zh/playground/gemini-omni-flash-1-1-edit) - [1.1 Flash Reference to Video](https://muapi.ai/zh/playground/gemini-omni-flash-1-1-reference-to-video) ## 资源 - [Playground 页面](https://muapi.ai/zh/playground/gemini-omni-text-to-video) - [API 文档](https://muapi.ai/zh/playground/gemini-omni-text-to-video/api) - [全站 llms.txt](https://muapi.ai/zh/llms.txt)