TL;DR: 本教程将向你展示如何使用 Gemini Omni Flash API 通过文本提示词和参考图像生成视频。借助 Atlas Cloud 的统一 API,你只需大约 15 分钟即可完成视频生成脚本的开发。无需 Google 账户审批,只需一个 Atlas Cloud API 密钥即可开始。
Google 官方的 Gemini API 快速入门指南并未专门涵盖 Gemini Omni Flash。本教程使用的是 Atlas Cloud 的统一 API 端点,无需通过 Google AI Studio 即可直接访问 Gemini Omni Flash。

r/GeminiAI 上一篇题为“Gemini Omni Flash API 访问权限:测试了 5 家提供商,按用例排名”的帖子在六天前发布后,迅速成为开发者评估方案的首选参考。其高赞评论直指核心:Google AI Studio 是上手最快的方式,但很容易触及速率限制。对于追求生产环境稳定性的开发者来说,需要一个不同的切入点。
Gemini Omni Flash 是 Google 的多模态视频生成模型,支持文本、图像、音频和视频的任意组合作为输入。它能生成长达 10 秒、分辨率在 720p 到 4K 之间的电影级视频。本教程将展示如何通过 Atlas Cloud 使用 Gemini Omni Flash API,该平台提供统一的 API 端点、按需付费模式,且不受 Google 账户速率限制。
本教程涵盖了 Gemini Omni API 的两种生成模式:文本转视频(Text-to-Video)和图像转视频(Image-to-Video)。所有代码示例均已在 Atlas Cloud 实时 API 环境下测试。
Gemini Omni Flash API 前置条件
你需要准备:
- Python 3.9+ 或 Node.js 18+
- 一个 Atlas Cloud 账户和 API 密钥(可免费注册)
- Python 的 requests 库,或 Node.js 的 axios 库
- 对 REST API 的基本了解
- 大约 15 分钟的开发时间
测试环境: macOS 14, Ubuntu 22.04, Windows 11 (WSL2)
定价参考(源自 Atlas Cloud 定价页,2026-06-02):
- 720p / 1080p:基础费用 USD0.20 + 每秒 USD0.10。一段 8 秒的 720p 视频成本为 USD1.00。
- 4K:基础费用 USD1.00 + 每秒 USD0.10。一段 8 秒的 4K 视频成本为 USD1.80。
使用 Gemini Omni API 构建的内容
在本教程结束时,你将拥有两个可用的脚本:一个用于从文本提示词生成视频,另一个用于将参考图像转换为视频。两个脚本共享相同的身份验证和轮询逻辑。架构非常直观:
plaintext1你的脚本 → Atlas Cloud API → Gemini Omni Flash → 视频 URL 2 (认证 + 队列) (生成) (输出)
脚本功能说明:
- 提交生成请求并获取 text
1prediction_id - 每隔 3 秒轮询一次状态端点,直到视频准备就绪
- 生成完成后打印输出视频的 URL
第 1 步:获取 Gemini Omni Flash API 密钥
在此步骤中,你将创建一个 Atlas Cloud 账户并生成 API 密钥,以便脚本能够通过 Gemini Omni Flash API 进行身份验证。
- 访问 atlascloud.ai 并注册免费账户。
- 在仪表盘中导航至 API Keys。
- 点击 Create new key,复制并妥善保存该密钥。
将密钥设置为环境变量,以免在脚本中硬编码:
plaintext1# macOS / Linux 2export ATLASCLOUD_API_KEY="your_api_key_here" 3 4# Windows (PowerShell) 5$env:ATLASCLOUD_API_KEY="your_api_key_here"
验证设置是否正确:
plaintext1echo $ATLASCLOUD_API_KEY
预期输出:
plaintext1your_api_key_here
注意: 切勿将 API 密钥提交到版本控制系统中。如果使用 python-dotenv 或 Node.js 的 dotenv,请通过 .env 文件将 ATLASCLOUD_API_KEY 添加到 .gitignore 中。
第 2 步:发起首个 Gemini Omni Flash API 请求
在此步骤中,你将向 Gemini Omni Flash API 提交一个文本转视频请求,并获取用于跟踪任务的
1prediction_idAtlas Cloud 上所有视频生成的端点为:
plaintext1POST https://api.atlascloud.ai/api/v1/model/generateVideo
Gemini Omni Flash 文本转视频的模型标识符为:
plaintext1google/gemini-omni-flash/text-to-video-developer
Python
plaintext1# gemini_omni_t2v.py 2import requests 3import os 4 5API_KEY = os.environ["ATLASCLOUD_API_KEY"] 6BASE_URL = "https://api.atlascloud.ai/api/v1/model" 7 8headers = { 9 "Content-Type": "application/json", 10 "Authorization": f"Bearer {API_KEY}" 11} 12 13payload = { 14 "model": "google/gemini-omni-flash/text-to-video-developer", 15 "prompt": "A young woman walks slowly through a rainy Tokyo street at night, neon reflections on wet pavement, cinematic slow motion, realistic lighting, 4K, film grain", 16 "duration": 8, # 秒数: 4, 6, 8, 或 10 17 "aspect_ratio": "16:9", # "16:9" 或 "9:16" 18 "resolution": "1080p", # "720p", "1080p", 或 "4k" 19 "seed": -1 # -1 为随机;设置整数可获得可复现的输出 20} 21 22response = requests.post(f"{BASE_URL}/generateVideo", headers=headers, json=payload) 23response.raise_for_status() 24 25prediction_id = response.json()["data"]["id"] 26print(f"Job submitted. Prediction ID: {prediction_id}")
Node.js
plaintext1// geminiOmniT2V.js 2const axios = require("axios"); 3 4const API_KEY = process.env.ATLASCLOUD_API_KEY; 5const BASE_URL = "https://api.atlascloud.ai/api/v1/model"; 6 7const headers = { 8 "Content-Type": "application/json", 9 Authorization: `Bearer ${API_KEY}`, 10}; 11 12const payload = { 13 model: "google/gemini-omni-flash/text-to-video-developer", 14 prompt: 15 "A young woman walks slowly through a rainy Tokyo street at night, neon reflections on wet pavement, cinematic slow motion, realistic lighting, 4K, film grain", 16 duration: 8, 17 aspect_ratio: "16:9", 18 resolution: "1080p", 19 seed: -1, 20}; 21 22axios 23 .post(`${BASE_URL}/generateVideo`, payload, { headers }) 24 .then((res) => { 25 const predictionId = res.data.data.id; 26 console.log(`Job submitted. Prediction ID: ${predictionId}`); 27 }) 28 .catch((err) => console.error(err.response?.data || err.message));
预期输出:
plaintext1Job submitted. Prediction ID: pred_abc123xyz
注意: API 会立即返回
。此时视频尚未准备好。你必须在第 3 步中轮询状态端点以获取输出 URL。text1prediction_id
第 3 步:轮询 Gemini Omni Flash 视频结果
在此步骤中,你将重复查询状态端点,直到视频生成完成并获得输出 URL。
Gemini Omni Flash 的视频生成是异步的。根据分辨率和服务器负载,完成时间通常在 30 秒到 3 分钟不等。状态端点为:
plaintext1GET https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}
可能的状态值:processing(处理中)、completed(已完成)、succeeded(成功)、failed(失败)。
Python
plaintext1# poll_result.py 2import requests 3import time 4import os 5 6API_KEY = os.environ["ATLASCLOUD_API_KEY"] 7BASE_URL = "https://api.atlascloud.ai/api/v1/model" 8 9headers = { 10 "Authorization": f"Bearer {API_KEY}" 11} 12 13def poll_video(prediction_id: str, timeout: int = 360) -> str: 14 """轮询直到视频准备就绪,然后返回输出 URL。""" 15 elapsed = 0 16 while elapsed < timeout: 17 response = requests.get( 18 f"{BASE_URL}/prediction/{prediction_id}", 19 headers=headers 20 ) 21 response.raise_for_status() 22 data = response.json()["data"] 23 status = data["status"] 24 25 if status in ("completed", "succeeded"): 26 video_url = data["outputs"][0] 27 print(f"Video ready: {video_url}") 28 return video_url 29 30 if status == "failed": 31 raise RuntimeError(f"Generation failed: {data}") 32 33 print(f"Status: {status} — waiting 3 seconds...") 34 time.sleep(3) 35 elapsed += 3 36 37 raise TimeoutError(f"Generation did not complete within {timeout} seconds.") 38 39# 替换为第 2 步中实际的 prediction_id 40video_url = poll_video("pred_abc123xyz")
Node.js
plaintext1// pollResult.js 2const axios = require("axios"); 3 4const API_KEY = process.env.ATLASCLOUD_API_KEY; 5const BASE_URL = "https://api.atlascloud.ai/api/v1/model"; 6const headers = { Authorization: `Bearer ${API_KEY}` }; 7 8async function pollVideo(predictionId, timeoutMs = 360000) { 9 const start = Date.now(); 10 while (Date.now() - start < timeoutMs) { 11 const res = await axios.get(`${BASE_URL}/prediction/${predictionId}`, { headers }); 12 const data = res.data.data; 13 14 if (data.status === "completed" || data.status === "succeeded") { 15 console.log("Video ready:", data.outputs[0]); 16 return data.outputs[0]; 17 } 18 if (data.status === "failed") throw new Error(`Generation failed: ${JSON.stringify(data)}`); 19 20 console.log(`Status: ${data.status} — waiting 3 seconds...`); 21 await new Promise((r) => setTimeout(r, 3000)); 22 } 23 throw new Error("Generation timed out."); 24} 25 26pollVideo("pred_abc123xyz");
预期输出:
plaintext1Status: processing — waiting 3 seconds... 2Status: processing — waiting 3 seconds... 3Video ready: https://storage.atlascloud.ai/outputs/result.mp4
将轮询间隔设为 3 秒而非 1 秒即可。由于 Gemini Omni Flash 任务在 1080p 下很少能在 30 秒内完成,每秒轮询只会增加多余的 API 调用。
注意: 输出视频在 Atlas Cloud 服务器上仅保存 48 小时。如果需要保留,请在生成后立即下载。
第 4 步:使用 Gemini Omni Flash API 进行图像转视频
在此步骤中,你将上传一张本地图像到 Atlas Cloud,并将其作为 Gemini Omni Flash API 进行图像转视频生成的参考。
图像转视频生成使用相同的端点,但需要不同的模型 ID 和
1imagesplaintext1google/gemini-omni-flash/image-to-video-developer
Gemini Omni Flash 图像转视频支持 1 到 7 张参考图像(PNG, JPEG, JPG, 或 WebP;单张最大 20 MB,最小 128×128 px)。它能确保生成视频中的视觉一致性,使人物和物体贯穿始终。

第 4a 步:上传图像
plaintext1# upload_image.py 2import requests 3import os 4 5API_KEY = os.environ["ATLASCLOUD_API_KEY"] 6UPLOAD_URL = "https://api.atlascloud.ai/api/v1/model/uploadMedia" 7 8headers = {"Authorization": f"Bearer {API_KEY}"} 9 10with open("reference.jpg", "rb") as f: 11 response = requests.post(UPLOAD_URL, headers=headers, files={"file": f}) 12 13response.raise_for_status() 14image_url = response.json()["data"]["url"] 15print(f"Uploaded image URL: {image_url}")
第 4b 步:提交图像转视频请求
plaintext1# gemini_omni_i2v.py 2import requests 3import os 4 5API_KEY = os.environ["ATLASCLOUD_API_KEY"] 6BASE_URL = "https://api.atlascloud.ai/api/v1/model" 7 8headers = { 9 "Content-Type": "application/json", 10 "Authorization": f"Bearer {API_KEY}" 11} 12 13payload = { 14 "model": "google/gemini-omni-flash/image-to-video-developer", 15 "prompt": "The character walks forward slowly, natural lighting, cinematic depth of field", 16 "images": [image_url], # 使用第 4a 步中返回的 URL 17 "duration": 8, 18 "aspect_ratio": "16:9", 19 "resolution": "1080p", 20 "seed": -1 21} 22 23response = requests.post(f"{BASE_URL}/generateVideo", headers=headers, json=payload) 24response.raise_for_status() 25 26prediction_id = response.json()["data"]["id"] 27print(f"Job submitted. Prediction ID: {prediction_id}") 28# 然后使用第 3 步中的 poll_video() 函数进行轮询
为了获得最佳效果,建议使用背景简洁、光线充足的参考图像。当主体与背景清晰分离时,模型能更一致地保持面部和服装细节。如果参考图包含复杂图案或严重的后期处理,可能会导致跨帧输出不一致。
注意: 仅支持 PNG、JPEG、JPG 和 WebP 格式的图像。超过 20 MB 的文件会导致 400 错误。
第 5 步:通过参数切换模型
通过 Atlas Cloud 访问 Gemini Omni API 的实际优势之一是,平台上的所有视频生成模型都共享相同的端点和轮询逻辑。从 Gemini Omni Flash 切换到其他模型只需修改一个模型参数。
plaintext1# 切换到 Seedance 2.0 文本转视频(在 Atlas Cloud 上的定价为 USD0.096/秒) 2payload["model"] = "bytedance/seedance-2-0/text-to-video" 3 4# 切换到 Veo 3.1 Lite 5payload["model"] = "google/veo-3-1/lite-text-to-video"
这使得多模型 A/B 测试变得非常简单。你可以在确定生产环境模型之前,将相同的提示词输入多个模型并对比输出质量。
Gemini Omni Flash API 故障排除
以下是使用 Gemini Omni Flash API 时最常见的五个问题及其解决方法。
| 问题 | 现象 | 解决方法 |
|---|---|---|
| 401 Unauthorized | {"error": "Invalid API key"} | 检查 ATLASCLOUD_API_KEY 环境变量是否已设置且未过期 |
| 400 Bad Request | {"error": "Invalid prompt"} | 提示词可能违反内容策略;请重写或移除受限内容 |
| 任务卡在 text | 6 分钟后仍未显示已完成 | 重试请求;这种情况很少见,但在高负载期间可能发生 |
| 视频 URL 返回 404 | URL 无法访问 | 输出文件 48 小时后过期;生成后请立即下载 |
| 429 Too Many Requests | 超过速率限制 | 在请求间增加延迟;重试时使用指数退避算法 |
仍有问题? 请访问 Atlas Cloud 文档 或通过平台支持渠道获取帮助。
后续步骤
既然你已经拥有了可用的文本转视频和图像转视频脚本,以下是扩展方案:
项目扩展建议:
- 结合 Seedance 2.0 添加带有音频输入的“参考转视频”功能,支持将最多 7 张参考图与音轨组合生成视频
- 构建一个批量生成流水线,并行提交多个提示词并异步收集结果
- 在脚本中添加成本估算:720p/1080p 的成本为 0.20 + (时长 * 0.10)
相关资源:
- Atlas Cloud 视频模型目录 — 所有可用视频生成模型
- Atlas Cloud 定价页 — 所有模型的完整定价
- Atlas Cloud API 文档 — 完整 API 参考
常见问题解答
什么是 Gemini Omni Flash API?
Gemini Omni Flash API 是 Google 的多模态视频生成接口,支持文本、图像、音频和视频的任意组合作为输入,输出电影级视频片段。它支持 4 到 10 秒的时长,720p 到 4K 的分辨率,以及横屏和竖屏比例。通过 Atlas Cloud 访问无需经过额外的 Google 审批流程。
Gemini Omni Flash API 的成本是多少?
在 Atlas Cloud 上,Gemini Omni Flash 的定价为基础费用 USD0.20 加上每秒 USD0.10(720p 和 1080p)。一段标准的 8 秒 1080p 视频成本为 USD1.00。对于 4K 输出,基础费用为 USD1.00 加每秒 USD0.10,8 秒 4K 视频成本为 USD1.80。所有计费均为按需付费,无最低消费限制(Atlas Cloud 定价,2026-06-02)。
使用 Atlas Cloud 访问 Gemini Omni Flash API 与 Google AI Studio 有什么区别?
Google AI Studio 提供对 Gemini 模型的直接访问,但需要 Google 账户,且受限于个人使用配额,很容易耗尽。Atlas Cloud 通过统一的 API 端点提供相同的 Gemini Omni Flash 模型,具有透明的秒级计费、无审批队列,并且使用同一 API 密钥即可访问其他 300 多个视频和图像模型。对于生产使用,Atlas Cloud 的统一 API 免去了为每个模型提供商管理不同凭证的麻烦。
Gemini Omni Flash 生成视频需要多长时间?
生成 8 秒 1080p 视频的典型耗时为 30 秒至 3 分钟,具体取决于服务器负载。该 API 是异步的:脚本提交作业后立即获取
1prediction_id我可以免费使用 Gemini Omni Flash API 吗?
Atlas Cloud 为新账户提供免费积分,可用于 Gemini Omni Flash 的生成。免费积分用完后,将转为按需付费模式,无需订阅。前往 atlascloud.ai 注册即可开始。






