# Gemini Omni 1.2 Flash API Google Gemini Omni 1.2 Flash 影片生成模型的完整 API 參考文件。 ## 模型變體 此 API 支援以下四種模型變體: | 模型 | ID | 說明 | |-------|-----|-------------| | **Gemini Omni 1.2 Flash Text to Video** | `gemini-omni-1.2-flash-text-to-video` | 根據文字提示詞生成影片 | | **Gemini Omni 1.2 Flash Image to Video** | `gemini-omni-1.2-flash-image-to-video` | 將必填的首幀影像轉為影片,可提供尾幀影像來引導畫面變化 | | **Gemini Omni 1.2 Flash Video Edit** | `gemini-omni-1.2-flash-video-edit` | 依據提示詞編輯現有影片 | | **Gemini Omni 1.2 Flash Reference to Video** | `gemini-omni-1.2-flash-reference-to-video` | 根據參考影像、參考影片或兩者的組合生成影片 | ## 模型比較 | 功能 | 文字生成影片 | 圖片生成影片 | 影片編輯 | 參考素材生成影片 | |---------|---------------|----------------|------------|--------------------| | 主要輸入 | 文字提示詞 | 首幀影像和文字提示詞 | 來源影片和文字提示詞 | 文字提示詞,以及至少一張參考影像或一段參考影片 | | 片長 | 3 至 15 秒 | 3 至 15 秒,提供尾幀時為 3 至 10 秒 | 來源影片不得超過 10 秒 | 3 至 15 秒 | | 可選解析度 | 360p, 720p, 1080p, 4k | 360p, 720p, 1080p, 4k | 360p, 720p, 1080p, 4k | 360p, 720p, 1080p, 4k | | 寬高比 | 16:9、9:16 | 16:9、9:16 | 不支援 | 16:9、9:16 | | 選用輸入 | 無 | 尾幀影像 | 無 | 最多 10 張影像和 3 段影片,至少提供一份參考素材 | ## 共用端點 所有 Gemini Omni 1.2 Flash 變體皆使用以下影片任務端點: ``` POST /api/v1/video/task ``` ## Gemini Omni 1.2 Flash Text to Video ### 必填參數 | 參數 | 型別 | 說明 | |-----------|------|-------------| | `model_name` | string | 必須為 `"gemini-omni-1.2-flash-text-to-video"` | | `prompt` | string | 以文字描述要生成的影片 | | `aspect_ratio` | string | 輸出寬高比,可選 `"16:9"` 或 `"9:16"` | | `resolution` | string | 輸出解析度,可選 `"360p"`、`"720p"`、`"1080p"` 或 `"4k"` | | `duration` | integer | 輸出影片的片長,範圍為 3 至 15 秒 | ### 請求範例 ```javascript const response = await fetch('https://api.flaq.ai/api/v1/video/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'gemini-omni-1.2-flash-text-to-video', prompt: 'A cinematic tracking shot follows a sailboat crossing a glowing ocean at sunset', aspect_ratio: '16:9', resolution: '1080p', duration: 12 }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Gemini Omni 1.2 Flash Image to Video ### 必填參數 | 參數 | 型別 | 說明 | |-----------|------|-------------| | `model_name` | string | 必須為 `"gemini-omni-1.2-flash-image-to-video"` | | `prompt` | string | 以文字描述預期的動作和場景變化 | | `image_url` | string | 首幀影像的 URL,必填 | | `aspect_ratio` | string | 輸出寬高比,可選 `"16:9"` 或 `"9:16"` | | `resolution` | string | 輸出解析度,可選 `"360p"`、`"720p"`、`"1080p"` 或 `"4k"` | | `duration` | integer | 輸出影片的片長。未指定尾幀時為 3 至 15 秒,提供 `image_end_url` 時為 3 至 10 秒 | ### 選用參數 | 參數 | 型別 | 說明 | |-----------|------|-------------| | `image_end_url` | string | 選用的尾幀影像 URL。提供此參數時,`duration` 必須介於 3 至 10 秒之間 | ### 請求範例 ```javascript { model_name: 'gemini-omni-1.2-flash-image-to-video', prompt: 'The girl walks toward the camera while the city lights shimmer behind her', image_url: 'https://example.com/start-frame.jpg', image_end_url: 'https://example.com/end-frame.jpg', aspect_ratio: '9:16', resolution: '1080p', duration: 8 } ``` ## Gemini Omni 1.2 Flash Video Edit ### 必填參數 | 參數 | 型別 | 說明 | |-----------|------|-------------| | `model_name` | string | 必須為 `"gemini-omni-1.2-flash-video-edit"` | | `prompt` | string | 以文字說明要對影片進行哪些修改 | | `video_url` | string | 來源影片的 URL。來源影片的片長不得超過 10 秒 | | `resolution` | string | 輸出解析度,可選 `"360p"`、`"720p"`、`"1080p"` 或 `"4k"` | **注意:** 影片編輯不支援 `aspect_ratio` 和 `duration`。請勿在請求中加入這兩個參數。 ### 請求範例 ```javascript { model_name: 'gemini-omni-1.2-flash-video-edit', prompt: 'A small ball rolls into the scene and captures the attention of the cat', video_url: 'https://example.com/source-video.mp4', resolution: '1080p' } ``` ## Gemini Omni 1.2 Flash Reference to Video 參考影像和參考影片可以單獨使用,也可以搭配使用。必須透過 `images` 或 `videos` 提供至少一張參考影像或一段參考影片。 ### 必填參數 | 參數 | 型別 | 說明 | |-----------|------|-------------| | `model_name` | string | 必須為 `"gemini-omni-1.2-flash-reference-to-video"` | | `prompt` | string | 以文字描述要生成的影片 | | `aspect_ratio` | string | 輸出寬高比,可選 `"16:9"` 或 `"9:16"` | | `resolution` | string | 輸出解析度,可選 `"360p"`、`"720p"`、`"1080p"` 或 `"4k"` | | `duration` | integer | 輸出影片的片長,範圍為 3 至 15 秒 | ### 選用參考素材 | 參數 | 型別 | 說明 | |-----------|------|-------------| | `images` | string[] | 最多可提供 10 個參考影像 URL。已提供參考影片時可省略 | | `videos` | string[] | 最多可提供 3 個參考影片 URL,每段影片不得超過 3 秒。已提供參考影像時可省略 | ### 請求範例 ```javascript { model_name: 'gemini-omni-1.2-flash-reference-to-video', prompt: 'Use the references to create a cinematic shot of a small boat approaching from the distance', aspect_ratio: '16:9', resolution: '1080p', duration: 12, images: ['https://example.com/boat-reference.jpg'], videos: ['https://example.com/motion-reference.mp4'] } ``` ## 回應格式 ### 初始回應 所有模型都會傳回一個供輪詢使用的 `task_id`: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "submitted" } } ``` ### 輪詢回應 輪詢 `GET /api/v1/video/{taskId}` 即可查詢任務狀態: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "succeed", "task_status_msg": null, "task_result": { "credit": 0.2, "videos": [ { "url": "https://example.com/generated-video.mp4" } ] } } } ``` ### 狀態值 - `submitted`:已接受任務,正在等待處理 - `processing`:正在生成影片 - `succeed`:影片生成完成 - `failed`:影片生成失敗 ## 最佳實務 1. **提示詞寫法**:清楚描述主體、動作、鏡頭移動、光線以及場景如何發展。 2. **必要設定**:請一律指定模型支援的解析度。除了影片編輯以外,也須指定模型支援的寬高比和片長。 3. **影像輸入**:請為首幀、尾幀和參考影像提供穩定且可公開存取的 URL。提供尾幀影像時,請將 `duration` 設為 3 至 10 秒。 4. **影片編輯輸入**:提交前請確認來源影片的片長不超過 10 秒。 5. **參考素材限制**:至少提供一張參考影像或一段參考影片。最多可提交 10 張影像和 3 段影片,每段參考影片不得超過 3 秒。