要点: 本教程将向您展示如何使用 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,请将 ATLASCLOUD_API_KEY 添加到 .gitignore 的 .env 文件中。
第 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,并将其用作图像转视频生成的参考。
图像转视频使用相同的端点,但需要不同的模型 ID 和
1imagesplaintext1google/gemini-omni-flash/image-to-video-developer
Gemini Omni Flash 图像转视频支持输入 1 到 7 张参考图片(PNG, JPEG, JPG, 或 WebP 格式;单张最大 20 MB,最小 128×128 像素)。它能保持生成视频中视觉身份的一致性,确保角色和物体在整个视频中保持不变。

第 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 张参考图与音轨的组合
- 构建批量生成流水线,并行提交多个提示词并异步收集结果
- 在脚本中添加成本估算器:成本 = 0.20 + (duration * 0.10) (针对 720p/1080p)
相关资源:
- 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)。
Google AI Studio 和 Atlas Cloud 在访问 Gemini Omni Flash API 时有何区别?
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 注册以开始使用。






