Gemini Omni 文字轉影片
使用文字轉影片端點建立非同步 Task。
概覽
使用文字轉影片端點搭配支援的模型。使用回傳的 Task ID 擷取其狀態,或提供 callback_url 以接收下方說明的回呼通知。
快速入門
- 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
- 選擇支援的模型,並傳送本文符合該模型結構描述的 POST 請求。
- 儲存返回的任務 ID,然後輪詢直到終止狀態,或處理下方說明的回呼。
端點
- 基礎 URL
https://runapi.ai- API 版本
v1- 身分驗證
Authorization: Bearer YOUR_API_TOKEN
支援的模型
開啟模型頁面以查看目前的定價、速率限制及商業用途詳情。
請求綱要
欄位及允許值取決於所選模型。若提供 callback_url,其將接收下方記錄的 Task 交付內容。
gemini-omni-flash-1-116 個欄位
aspect_ratiostring輸出長寬比。
允許的值:16:9, 9:16
audio_idsarray由 create-audio 返回的音訊預設 ID。
項目數上限:3
callback_urlstring用於終態 Task 回呼的 Webhook URL。
character_idsarray由 create-character 回傳的角色 ID;雙圖角色會佔用共享七個參考單位中的兩個。
項目數上限:3
duration_secondsinteger輸出時長(秒)。
允許的值:4, 6, 8, 10
first_frame_image_urlstring公開首幀圖片 URL;與參考圖片、音訊 ID、影片片段及角色 ID 互斥。
last_frame_image_urlstring公開最後一幀影像 URL;需搭配 first_frame_image_url。
modelstring模型 slug;省略時預設為 gemini-omni-text-to-video。
output_resolutionstring輸出解析度。
允許的值:360p, 720p, 1080p, 4k
預設值: 720p
promptstring影片生成提示。
邊界:20000
reference_image_urlsarray公開參考影像 URL;影像、影片片段與角色共用七個單位的參考限制。
項目數上限:7
seedinteger確定性生成種子。
範圍:0 - 2147483647
video_listarray來源影片片段;每個片段消耗兩個參考單位。
項目數上限:1
video_list[].endsnumber片段結束時間(秒);必須大於開始時間,且不超過開始時間後 10 秒。
邊界:0
video_list[].startnumber片段開始時間(秒)。
邊界:0
video_list[].urlstring公開來源影片 URL。
gemini-omni-flash-preview5 個欄位
aspect_ratiostring輸出長寬比。
允許的值:16:9, 9:16
預設值: 16:9
callback_urlstring用於終態 Task 回呼的 Webhook URL。
modelstring模型 slug;省略時預設為 gemini-omni-text-to-video。
output_resolutionstring輸出解析度。
允許的值:720p
預設值: 720p
promptstring影片生成提示。
邊界:20000
gemini-omni-text-to-video14 個欄位
aspect_ratiostring輸出長寬比。
允許的值:16:9, 9:16
audio_idsarray由 create-audio 返回的音訊預設 ID。
項目數上限:3
callback_urlstring用於終態 Task 回呼的 Webhook URL。
character_idsarray由 create-character 回傳的角色 ID;雙圖角色會佔用共享七個參考單位中的兩個。
項目數上限:3
duration_secondsinteger輸出時長(秒)。
允許的值:4, 6, 8, 10
modelstring模型 slug;省略時預設為 gemini-omni-text-to-video。
預設值:gemini-omni-text-to-video
output_resolutionstring輸出解析度。
允許的值:720p, 1080p, 4k
預設值: 720p
promptstring影片生成提示。
邊界:20000
reference_image_urlsarray公開參考影像 URL;影像、影片片段與角色共用七個單位的參考限制。
項目數上限:7
seedinteger確定性生成種子。
範圍:0 - 2147483647
video_listarray來源影片片段;每個片段消耗兩個參考單位。
項目數上限:1
video_list[].endsnumber片段結束時間(秒);必須大於開始時間,且不超過開始時間後 10 秒。
邊界:0
video_list[].startnumber片段開始時間(秒)。
邊界:0
video_list[].urlstring公開來源影片 URL。
條件規則
當所有列出的條件均符合時,這些需求即適用。
-
當
first_frame_image_url = {"present" => true},model = gemini-omni-flash-1-1- 必填
- 不接受
reference_image_urls,audio_ids,video_list,character_ids
-
當
last_frame_image_url = {"present" => true},model = gemini-omni-flash-1-1- 必填
first_frame_image_url- 不接受
-
當
model = gemini-omni-flash-preview- 必填
- 不接受
reference_image_urls,audio_ids,video_list,character_ids,first_frame_image_url,last_frame_image_url,duration_seconds,seed
-
當
model = gemini-omni-text-to-video- 必填
- 不接受
first_frame_image_url,last_frame_image_url
建立接受記錄
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
},
"task_replayed": {
"type": "boolean"
}
},
"required": [
"id",
"status",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "processing"
}
輪詢處理中
GET /api/v1/gemini_omni/text_to_video/:id
回應綱要
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
}
},
"required": [
"id",
"status",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "processing"
}
輪詢已完成
GET /api/v1/gemini_omni/text_to_video/:id
回應綱要
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
},
"videos": {
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
}
},
"required": [
"id",
"status",
"videos",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "completed",
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
輪詢失敗
GET /api/v1/gemini_omni/text_to_video/:id
回應綱要
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"error": {
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"error": "Task processing failed.",
"id": "tsk_reference_demo",
"status": "failed"
}
客戶回呼:已完成
POST callback_url
回應綱要
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
},
"videos": {
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
}
},
"required": [
"id",
"status",
"videos"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"id": "tsk_reference_demo",
"status": "completed",
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
客戶回呼:失敗
POST callback_url
回應綱要
{
"properties": {
"error": {
"oneOf": [
{
"type": "string"
},
{
"properties": {
"code": {
"type": "string"
},
"limit_cents": {
"type": "integer"
},
"message": {
"type": "string"
},
"reset_at": {
"format": "date-time",
"type": [
"string",
"null"
]
},
"used_cents": {
"type": "integer"
},
"window": {
"enum": [
"1h",
"1d",
"7d",
"daily",
"weekly",
"monthly",
"lifetime"
],
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object",
"unevaluatedProperties": false
}
]
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": {
"code": "generation_failed",
"message": "Task processing failed."
},
"id": "tsk_reference_demo",
"status": "failed"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Authentication required"
}
錯誤
GET /api/v1/gemini_omni/text_to_video/:id
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Authentication required"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"oneOf": [
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "人類可讀的驗證摘要。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "以公開請求欄位為索引鍵的驗證訊息,每個欄位包含一組人類可讀的字串陣列。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
回應範例
{
"error": "model must be one of: gemini-omni-flash-1-1, gemini-omni-flash-preview, gemini-omni-text-to-video"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Insufficient balance"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "API key credit limit exceeded"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "The request uses features that are not supported for the selected model"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Rate limit reached. Please retry later."
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Service under maintenance, please try again later"
}
錯誤
POST /api/v1/gemini_omni/text_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "The request timed out"
}
錯誤
GET /api/v1/gemini_omni/text_to_video/:id
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Task with id 'tsk_reference_demo' not found"
}
產生的程式碼範例
直接使用 cURL,或為您的程式語言安裝 SDK。每個範例均會提交本參考中所示的已驗證請求。
安裝
pip install runapi-gemini-omni
import os
from runapi.gemini_omni import GeminiOmniClient
client = GeminiOmniClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_video.create(
model="gemini-omni-text-to-video",
prompt="A presenter walks through a bright studio.",
duration_seconds=4
)