Gemini Omni Flash:透過聊天模型生成影片
Omni 使用 chat/completions 介面接收文字與多媒體輸入,並可在模型回應中產生媒體結果。它與非同步 Media API 的參數和回傳格式不同。
- 訊息可包含圖片、GIF、音訊或影片 URL;依支援格式提供公開 URL 或資料內容。
- 保留標準 OpenAI 相容 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 金鑰寫入公開程式碼或瀏覽器前端。