Gemini Omni Flash (gemini-omni-flash-preview) 是高效能多模態模型,專為高速生成影片、編輯影片和電影控制而設計。Gemini Omni 具備下列核心功能,與先前的影片模型有所不同:
- 原生多模態:可同時處理文字、圖片、音訊和影片,提供更連貫、一致且可控的輸出內容。
- 對話式修圖:透過 Interactions API 啟用,可讓您透過自然語言對話,反覆調整和編輯影片。描述想變更的內容,模型就會套用編輯效果,同時保留影片中你不想變更的部分。
- 世界知識:Gemini Omni 結合了物理學知識與 Gemini 的歷史、科學和文化背景知識,彌合了寫實主義與有意義的敘事之間的差距。
文字轉影片生成
根據文字提示詞生成影片。模型會根據文字說明生成含音訊的影片。撰寫提示時,請加入場景描述、攝影機移動、燈光和情境等詳細資訊,以獲得最佳效果。
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input="A marble rolling fast on a chain reaction style track, continuous smooth shot."
)
with open("marble.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: 'A marble rolling fast on a chain reaction style track, continuous smooth shot.',
});
if (interaction.output_video?.data) {
fs.writeFileSync('marble.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash-preview",
"input": "A marble rolling fast on a chain reaction style track, continuous smooth shot."
}'
REST 回應結構定義
便利性欄位 interaction.output_video 僅適用於 SDK。直接使用 REST API 時,請從 steps 陣列取得影片輸出內容。
原始 REST JSON 結構:
{
"steps": [
{ "type": "user_input", "content": [{"type": "text", "text": "..."}] },
{ "type": "thought", "content": [{"text": "...", "type": "thought"}] },
{
"type": "model_output",
"content": [
{
"type": "video",
"mime_type": "video/mp4",
"data": "AAAAIGZ0eXBpc29t..." // Base64 encoded video data
}
]
}
],
"id": "v1_...",
"status": "completed",
"model": "gemini-omni-flash-preview",
"object": "interaction"
}
控制顯示比例
將 aspect_ratio 設為 "9:16",即可製作直向影片。預設為橫向 (16:9)。
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input="A futuristic city with neon lights and flying cars, cyberpunk style",
response_format={
"type": "video", # optional
"aspect_ratio": "9:16" # Supported values: "9:16", "16:9"
}
)
with open("example.mp4", "wb") as f:
f.write(base64.b64decode(interaction.output_video.data))
JavaScript
import { GoogleGenAI } from '@google/genai';
import * as fs from 'fs';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-omni-flash-preview',
input: 'A futuristic city with neon lights and flying cars, cyberpunk style',
response_format: {
type: 'video', // optional
aspect_ratio: '9:16' // Supported values: '9:16', '16:9'
},
});
if (interaction.output_video?.data) {
fs.writeFileSync('example.mp4', Buffer.from(interaction.output_video.data, 'base64'));
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash-preview",
"input": "A futuristic city with neon lights and flying cars, cyberpunk style",
"response_format": {
"type": "video",
"aspect_ratio": "9:16"
}
}'
以圖片生成影片
你可以提供參考圖像和文字提示詞。模型會根據提示決定如何使用圖片。這項功能可讓產品照片、插圖或相片栩栩如生。
以下範例說明如何使用魚兒躍出水面的手繪參考圖像:
輸入下列提示詞:
turn this into realistic footage, using the drawing only as a guide for movement, do not show the drawing in the final video
生成寫實的繪圖影片。
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-omni-flash-preview",
input=[
{"type": "image", "data"