Gemini Omni Flash:通过聊天模型生成视频
Omni 通过 chat/completions 接收文字和多媒体,并可在响应中生成媒体结果。它与异步 Media API 的参数和返回格式不同。
- 消息可包含受支持的图片、GIF、音频或视频 URL。
- 保持 OpenAI-compatible messages 结构并使用完整 Omni 模型 ID。
- 同一功能也可在 Studio 和 Telegram 机器人中使用。
完整示例
原始指南中的可执行示例完整保留如下。只运行适用于你的工具和操作系统的代码块。
bash
curl https://nordrouter.com/v1/chat/completions \
-H "Authorization: Bearer sk-nr-YOUR-KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-omni-flash-preview",
"messages": [{"role": "user", "content": "Generate a video: a red balloon floating over a calm sea"}],
"modalities": ["image", "text"],
"max_tokens": 4000
}'json
{
"model": "google/gemini-omni-flash-preview",
"messages": [{
"role": "user",
"content": [
{ "type": "text", "text": "Create an ad: use the person from the photo, motion from the reference video, and cut to the audio beat" },
{ "type": "image_url", "image_url": { "url": "https://example.com/hero.png" } },
{ "type": "image_url", "image_url": { "url": "https://example.com/style.gif" } },
{ "type": "input_audio", "input_audio": { "data": "BASE64_AUDIO", "format": "wav" } },
{ "type": "video_url", "video_url": { "url": "https://example.com/motion.mp4" } }
]
}],
"modalities": ["image", "text"],
"max_tokens": 4000
}json
{
"choices": [{
"message": {
"role": "assistant",
"content": "I've generated the video for you.",
"videos": [{ "type": "video_url",
"video_url": { "url": "https://nordrouter.com/media/file/…" } }]
}
}],
"usage": { "prompt_tokens": 18, "completion_tokens": 58197, "total_tokens": 58215 }
}官方资料与相关链接
| Omni Flash | Regular video models (/media/generate) | |
|---|---|---|
| Endpoint | POST /v1/chat/completions | POST /media/generate |
| Billing | per token (input $0.2322 / output $1.3932 per 1M) | flat per generation |
| Speed | ~40–60 s, synchronous response | task + polling |
| Video price | ≈ $0.08 | from $0.11 |
相关指南
先用最小文本请求验证连接,再添加流式输出、工具调用、图片等高级功能。不要把 API key 放入公开代码或浏览器前端。