您可以使用 Gemini Omni 1.2 Flash,透過 Agent Platform API 將影片從較低解析度 (360p 或 720p) 放大至較高解析度 (720p、1080p 或 4K)。獨立影片放大功能可讓您以較低解析度反覆調整提示,並只放大最終選定的影片,無論是前一個回合的影片,還是先前生成並儲存在 Cloud Storage 的影片。
下列模型支援影片畫質提升功能:
按一下即可展開支援的模型
支援的解析度和規格
獨立影片畫質提升功能支援下列解析度轉換和輸入限制:
- 360p 輸入影片:放大至
720p或1080p。不支援在單一要求中直接從360p放大至4k。 - 720p 輸入影片:提升至
1080p或4k。不支援從1080p升級至4k。 - 顯示比例:
16:9(橫向) 或9:16(直向)。 - 影格率:每秒 24 個影格 (輸出影片會保留這個影格率)。
- 時間長度:最長 15 秒。
- 詞元用量和定價:獨立影片放大功能會略過文字推論,且一律不會產生輸入詞元 (
total_input_tokens: 0)。輸出影片詞元會根據來源和目標解析度組合,以與所有其他 Omni 1.2 Flash 工作相同的輸出影片詞元價格計費 (360p至720p和720p至1080p為每秒2,896個輸出影片詞元、360p至1080p為每秒5,792個輸出影片詞元,以及720p至4k為每秒11,584個輸出影片詞元)。
申請規定
傳送獨立影片放大要求時,請確認要求符合下列規定:
- 指定
task: "upscale":您必須將generation_config.video_config.task設為"upscale"。如果您省略task: "upscale",API 會將要求解讀為影片編輯 ("edit") 作業。 - 指定目標
resolution:您必須在response_format中指定目標resolution("720p"、"1080p"或"4k")。如果省略目標resolution,系統會傳回錯誤。 - 提供影片來源:在
input("type": "video") 中提供輸入影片,或設定previous_interaction_id,放大前一個有狀態輪次中生成的影片。在多輪互動中,系統只會考量前一輪互動,找出要升級的影片。 - 選用參數:您可以指定
generation_config.seed,以取得可重現的輸出內容,並附加自訂中繼資料標籤 (labels),以便整理要求及追蹤已計費用。
事前準備
- 登入 Google Cloud 帳戶。如果您未曾使用過 Google Cloud,歡迎建立帳戶,親自體驗實際使用我們產品的成效。新客戶還能獲得價值 $300 美元的免費抵免額,用於執行、測試及部署工作負載。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
設定環境的驗證機制。
請根據您打算如何使用本頁範例,選取對應的分頁標籤:
控制台
使用 Google Cloud 控制台存取 Google Cloud 服務和 API 時,不需要設定驗證機制。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI。
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」一節。
使用 Omni 1.2 Flash 提升影片解析度
如要使用 Omni 1.2 Flash 提升影片畫質,請選取下列其中一種互動模式:
REST
影片放大作業可能需要一分鐘以上才能完成。您可以根據工作流程,從多種互動模式中選擇:
- 同步:無狀態 (上傳的影片):將
store設為false,即可在單一要求中放大 Cloud Storage 的 360p 或 720p 影片,不需在伺服器保留互動狀態。 - 同步:有狀態 (前一輪):參考前一輪有狀態對話的
previous_interaction_id,放大先前生成的 360p 或 720p 影片。 - 同步:有狀態串流:將
store和stream設為true,即可在單一step.delta事件 ("type": "video") 中串流互動狀態更新和輸出影片。 - 非同步:將
background設為true,在背景執行影片放大作業,稍後再使用互動 ID 擷取結果。
儲存和非同步互動資料最多會保留 7 天。
在 response_format 中設定 "delivery": "uri" 時,也必須指定 gcs_uri。如果 "delivery" 為 "uri",但省略 gcs_uri,系統會傳回 400 INVALID_ARGUMENT 錯誤。
一元回應會在 steps[].content[].uri 中傳回 Cloud Storage URI,串流回應則會在 delta.uri 中傳回。如要改為在回應中傳回內嵌影片位元組,請設定 "delivery": "inline" 並省略 gcs_uri (當 "delivery" 為 "inline" 時,不支援 gcs_uri)。使用內嵌傳送時,影片輸出會以 base64 編碼位元組字串的形式傳回,並與 steps[].content[].data (一元 POST 和 GET) 或 delta.data (SSE step.delta) 中的 "mime_type": "video/mp4" 一起傳回。與文字或音訊差異不同,內嵌影片不會分散在多個 step.delta 事件中,每個放大影片都會在一個 step.delta 事件中以單一完整的 base64 酬載傳送。
如果是大型或高解析度影片,請搭配使用 "delivery": "uri" 和 gcs_uri,避免大型 HTTP 或單一事件 SSE 回應酬載。
如要進一步瞭解如何搭配使用 Gemini Omni 模型和 Interactions API,請參閱「Interactions API」。
同步:無狀態
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
MODEL_ID:代表要使用的模型 ID 的字串。可接受的值如下:"gemini-omni-1.2-flash"
-
CLOUD_STORAGE_VIDEO_URI:代表 Cloud Storage URI 的字串,其中包含輸入影片 (360p 或 720p,最長 15 秒)。例如:"gs://video-bucket/input/video.mp4"。 -
VIDEO_MIME:代表影片 MIME 類型的字串。可接受的值如下:video/3gppvideo/mp4video/mpegvideo/quicktimevideo/webmvideo/x-flvvideo/x-ms-wmv
-
CLOUD_STORAGE_OUTPUT_URI:代表 Cloud Storage bucket 的字串,用於儲存放大後的影片 (例如"gs://video-bucket/output/")。如果delivery設為"uri",則必須提供這個參數。如要改為在回應中傳回內嵌影片位元組,請設定"delivery": "inline",並從response_format中省略gcs_uri。 -
OUTPUT_RESOLUTION: 必要:代表目標輸出解析度的字串。支援的值取決於輸入影片解析度:- 360p 輸入影片:
"720p"或"1080p" - 720p 輸入影片:
"1080p"或"4k"
- 360p 輸入影片:
HTTP 方法和網址:
POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions
JSON 要求內文:
{
"model": "MODEL_ID",
"store": false,
"input": [
{
"type": "video",
"uri": "CLOUD_STORAGE_VIDEO_URI",
"mime_type": "VIDEO_MIME"
}
],
"response_format": [
{
"type": "video",
"delivery": "uri",
"gcs_uri": "CLOUD_STORAGE_OUTPUT_URI",
"resolution": "OUTPUT_RESOLUTION"
}
],
"generation_config": {
"video_config": {
"task": "upscale"
}
}
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X POST \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions" | Select-Object -Expand Content
{
"id": "INTERACTION_ID",
"model": "gemini-omni-1.2-flash",
"status": "completed",
"usage": {
"total_tokens": 28960,
"total_input_tokens": 0,
"output_tokens_by_modality": [
{
"modality": "video",
"tokens": 28960
}
],
"total_output_tokens": 28960
},
"steps": [
{
"type": "model_output",
"content": [
{
"type": "video",
"uri": "gs://some/output_path/123.mp4",
"mime_type": "video/mp4"
}
]
}
],
"object": "interaction",
"role": "model",
"created": "2026-11-05T02:17:56Z",
"updated": "2026-11-05T02:17:56Z"
}
同步:有狀態
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
MODEL_ID:代表要使用的模型 ID 的字串。可接受的值如下:"gemini-omni-1.2-flash"
-
PREVIOUS_INTERACTION_ID:緊接在前的有狀態對話互動 ID,用於生成 360p 或 720p 影片 (最長 15 秒)。 -
CLOUD_STORAGE_OUTPUT_URI:代表 Cloud Storage bucket 的字串,用於儲存放大後的影片 (例如"gs://video-bucket/output/")。如果delivery設為"uri",則必須提供這個參數。如要改為在回覆中傳回內嵌影片位元組,請設定"delivery": "inline",並從response_format省略gcs_uri。 -
OUTPUT_RESOLUTION: 必要:代表目標輸出解析度的字串。支援的值取決於前一個回合的影片解析度:- 360p 影片:
"720p"或"1080p" - 720p 影片:
"1080p"或"4k"
- 360p 影片:
HTTP 方法和網址:
POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions
JSON 要求內文:
{
"model": "MODEL_ID",
"previous_interaction_id": "PREVIOUS_INTERACTION_ID",
"background": false,
"store": true,
"stream": false,
"input": [
{
"type": "user_input",
"content": [
{
"type": "text",
"text": "Upsample video."
}
]
}
],
"response_format": [
{
"type": "video",
"delivery": "uri",
"gcs_uri": "CLOUD_STORAGE_OUTPUT_URI",
"resolution": "OUTPUT_RESOLUTION"
}
],
"generation_config": {
"video_config": {
"task": "upscale"
}
}
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X POST \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions" | Select-Object -Expand Content
{
"id": "INTERACTION_ID",
"previous_interaction_id": "PREVIOUS_INTERACTION_ID",
"model": "gemini-omni-1.2-flash",
"status": "completed",
"usage": {
"total_tokens": 28960,
"total_input_tokens": 0,
"output_tokens_by_modality": [
{
"modality": "video",
"tokens": 28960
}
],
"total_output_tokens": 28960
},
"steps": [
{
"type": "model_output",
"content": [
{
"type": "video",
"uri": "gs://some/output_path/123.mp4",
"mime_type": "video/mp4"
}
]
}
],
"object": "interaction",
"role": "model",
"created": "2026-11-05T02:17:56Z",
"updated": "2026-11-05T02:17:56Z"
}
INTERACTION_ID 取得放大影片:
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
INTERACTION_ID:要求中的互動 ID。
HTTP 方法和網址:
GET https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X GET \
-H "Authorization: Bearer TOKEN" \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID"
PowerShell
執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID" | Select-Object -Expand Content
{
"id":"INTERACTION_ID",
"model":"gemini-omni-1.2-flash",
"status":"completed",
"usage":{
"total_tokens":29435,
"total_input_tokens":150,
"input_tokens_by_modality":[
{
"modality":"text",
"tokens":26
},
{
"modality":"image",
"tokens":124
}
],
"output_tokens_by_modality": [
{
"modality": "video",
"tokens": 28832
}
],
"total_output_tokens":28832,
"total_thought_tokens":453
},
"steps":[
{
"type": "user_input",
"content": [
{
"type": "text",
"text": "5 second, 9:16 video. Use the image as the first frame."
},
{
"type": "image",
"uri": "gs://some/path",
"mime_type": "image/png"
}
]
},
{
"type":"thought",
"summary":[
{
"type":"text",
"text":"MODEL THOUGHTS"
}
]
},
{
"type":"model_output",
"content":[
{
"type":"video",
"uri":"gs://some/output_path/123.mp4",
"mime_type":"video/mp4"
}
]
}
],
"object":"interaction",
"role":"model",
"created":"2026-05-29T02:17:56Z",
"updated":"2026-05-29T02:17:56Z"
}
使用內嵌傳送時 ("delivery": "inline",省略 gcs_uri),model_output 步驟會傳回完整影片,做為 steps[].content[].data 中 "mime_type": "video/mp4" 旁的 Base64 編碼位元組字串,而非 uri:
{
"type": "model_output",
"content": [
{
"type": "video",
"data": "BASE64_ENCODED_VIDEO",
"mime_type": "video/mp4"
}
]
}同步:有狀態串流
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
MODEL_ID:代表要使用的模型 ID 的字串。可接受的值如下:"gemini-omni-1.2-flash"
-
CLOUD_STORAGE_VIDEO_URI:代表 Cloud Storage URI 的字串,其中包含輸入影片 (360p 或 720p,最長 15 秒)。例如:"gs://video-bucket/input/video.mp4"。 -
VIDEO_MIME:代表影片 MIME 類型的字串。可接受的值如下:video/3gppvideo/mp4video/mpegvideo/quicktimevideo/webmvideo/x-flvvideo/x-ms-wmv
-
CLOUD_STORAGE_OUTPUT_URI:代表 Cloud Storage bucket 的字串,用於儲存放大後的影片 (例如"gs://video-bucket/output/")。如果delivery設為"uri",則必須提供這個參數。如要改為在回應中傳回內嵌影片位元組,請設定"delivery": "inline",並從response_format中省略gcs_uri。 -
OUTPUT_RESOLUTION: 必要:代表目標輸出解析度的字串。支援的值取決於輸入影片解析度:- 360p 輸入影片:
"720p"或"1080p" - 720p 輸入影片:
"1080p"或"4k"
- 360p 輸入影片:
HTTP 方法和網址:
POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions
JSON 要求內文:
{
"model": "MODEL_ID",
"background": false,
"store": true,
"stream": true,
"input": [
{
"type": "user_input",
"content": [
{
"type": "video",
"uri": "CLOUD_STORAGE_VIDEO_URI",
"mime_type": "VIDEO_MIME"
}
]
}
],
"response_format": [
{
"type": "video",
"delivery": "uri",
"gcs_uri": "CLOUD_STORAGE_OUTPUT_URI",
"resolution": "OUTPUT_RESOLUTION"
}
],
"generation_config": {
"video_config": {
"task": "upscale"
}
}
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X POST \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions" | Select-Object -Expand Content
event: interaction.created
data: {"interaction":{"id":"INTERACTION_ID","status":"in_progress","object":"interaction","model":"gemini-omni-1.2-flash"},"event_type":"interaction.created"}
event: interaction.status_update
data: {"interaction_id":"INTERACTION_ID","status":"in_progress","event_type":"interaction.status_update"}
event: step.start
data: {"index":0,"step":{"type":"model_output"},"event_type":"step.start"}
event: step.delta
data: {"index":0,"delta":{"mime_type":"video/mp4","uri":"gs://some/output_path/123.mp4","type":"video"},"event_id":"EVENT_ID","event_type":"step.delta"}
event: step.stop
data: {"index":0,"event_type":"step.stop"}
event: interaction.completed
data: {"interaction":{"id":"INTERACTION_ID","status":"completed","usage":{"total_tokens":28960,"total_input_tokens":0,"total_output_tokens":28960,"output_tokens_by_modality":[{"modality":"video","tokens":28960}]},"created":"2026-11-05T21:26:20Z","updated":"2026-11-05T21:26:20Z","event_id":"EVENT_ID","object":"interaction","model":"gemini-omni-1.2-flash"},"event_id":"EVENT_ID","event_type":"interaction.completed"}
event: done
data: [DONE]
使用內嵌傳送時 ("delivery": "inline",省略 gcs_uri),影片 step.delta 事件會傳回 delta.data 中的影片位元組,做為 base64 編碼字串,並與 "mime_type": "video/mp4" 一起傳回,而不是 delta.uri:
event: step.delta
data: {"index":0,"delta":{"mime_type":"video/mp4","data":"BASE64_ENCODED_VIDEO","type":"video"},"event_id":"EVENT_ID","event_type":"step.delta"}
與文字 ("type": "text") 或音訊 ("type": "audio") 差異不同,內嵌影片不會在多個 step.delta 事件中分塊。每部放大影片都會在一個 step.delta 事件 ("type": "video") 中,以單一完整的 Base64 編碼酬載形式傳送。請勿串連多個影片 step.delta 事件中的 delta.data。如果是大型或高解析度影片,請搭配使用 "delivery": "uri" 和 Cloud Storage bucket (gcs_uri),避免單一事件 SSE 酬載過大。
INTERACTION_ID 搭配 `?stream=true`,串流播放儲存的互動和放大影片:
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
INTERACTION_ID:要求中的互動 ID。
HTTP 方法和網址:
GET https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID?stream=true
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X GET \
-H "Authorization: Bearer TOKEN" \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID?stream=true"
PowerShell
執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID?stream=true" | Select-Object -Expand Content
event: interaction.created
data: {"interaction":{"id":"INTERACTION_ID","status":"in_progress","object":"interaction","model":"gemini-omni-1.2-flash"},"event_type":"interaction.created"}
event: interaction.status_update
data: {"interaction_id":"INTERACTION_ID","status":"in_progress","event_type":"interaction.status_update"}
event: step.start
data: {"index":0,"step":{"type":"thought"},"event_type":"step.start"}
event: step.delta
data: {"index":0,"delta":{"content":{"text":"MODEL THOUGHTS","type":"text"},"type":"thought_summary"},"event_id":"EVENT_ID","event_type":"step.delta"}
event: step.delta
data: {"index":0,"delta":{"content":{"text":"MODEL THOUGHTS","type":"text"},"type":"thought_summary"},"event_id":"EVENT_ID","event_type":"step.delta"}
event: step.delta
data: {"index":0,"delta":{"signature":"...","type":"thought_signature"},"event_type":"step.delta"}
event: step.stop
data: {"index":0,"event_type":"step.stop"}
event: step.start
data: {"index":1,"step":{"type":"model_output"},"event_type":"step.start"}
event: step.delta
data: {"index":1,"delta":{"mime_type":"video/mp4","uri":"gs://some/output_path/123.mp4","type":"video"},"event_id":"EVENT_ID","event_type":"step.delta"}
event: step.stop
data: {"index":1,"event_type":"step.stop"}
event: interaction.completed
data: {"interaction":{"id":"INTERACTION_ID","status":"completed","usage":{"total_tokens":17664,"total_input_tokens":21,"input_tokens_by_modality":[{"modality":"text","tokens":21}],"total_output_tokens":17376,"output_tokens_by_modality":[{"modality":"video","tokens":17376}],"total_thought_tokens":267},"created":"2026-08-12T21:33:08Z","updated":"2026-08-12T21:33:08Z","event_id":"EVENT_ID","object":"interaction","model":"gemini-omni-1.2-flash"},"event_id":"EVENT_ID","event_type":"interaction.completed"}
event: done
data: [DONE]
使用內嵌傳送時 ("delivery": "inline",省略 gcs_uri),影片 step.delta 事件會傳回 delta.data 中的影片位元組,做為 base64 編碼字串,並與 "mime_type": "video/mp4" 一起傳回,而不是 delta.uri:
event: step.delta
data: {"index":1,"delta":{"mime_type":"video/mp4","data":"BASE64_ENCODED_VIDEO","type":"video"},"event_id":"EVENT_ID","event_type":"step.delta"}
與文字 ("type": "text") 或音訊 ("type": "audio") 差異不同,內嵌影片不會在多個 step.delta 事件中分塊。每個生成的影片都會在一個 step.delta 事件 ("type": "video") 中,以單一完整的 Base64 編碼酬載形式傳送。請勿跨多個影片 step.delta 事件串連 delta.data。如果是大型或高解析度影片,請搭配使用 "delivery": "uri" 和 Cloud Storage bucket (gcs_uri),避免單一事件 SSE 酬載過大。
非同步
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
MODEL_ID:代表要使用的模型 ID 的字串。可接受的值如下:"gemini-omni-1.2-flash"
-
CLOUD_STORAGE_VIDEO_URI:代表 Cloud Storage URI 的字串,其中包含輸入影片 (360p 或 720p,最長 15 秒)。例如:"gs://video-bucket/input/video.mp4"。 -
VIDEO_MIME:代表影片 MIME 類型的字串。可接受的值如下:video/3gppvideo/mp4video/mpegvideo/quicktimevideo/webmvideo/x-flvvideo/x-ms-wmv
-
CLOUD_STORAGE_OUTPUT_URI:代表 Cloud Storage bucket 的字串,用於儲存放大後的影片 (例如"gs://video-bucket/output/")。如果delivery設為"uri",則必須提供這個參數。如要改為在回應中傳回內嵌影片位元組,請設定"delivery": "inline",並從response_format中省略gcs_uri。 -
OUTPUT_RESOLUTION: 必要:代表目標輸出解析度的字串。支援的值取決於輸入影片解析度:- 360p 輸入影片:
"720p"或"1080p" - 720p 輸入影片:
"1080p"或"4k"
- 360p 輸入影片:
HTTP 方法和網址:
POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions
JSON 要求內文:
{
"model": "MODEL_ID",
"background": true,
"input": [
{
"type": "video",
"uri": "CLOUD_STORAGE_VIDEO_URI",
"mime_type": "VIDEO_MIME"
}
],
"response_format": [
{
"type": "video",
"delivery": "uri",
"gcs_uri": "CLOUD_STORAGE_OUTPUT_URI",
"resolution": "OUTPUT_RESOLUTION"
}
],
"generation_config": {
"video_config": {
"task": "upscale"
}
}
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X POST \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions" | Select-Object -Expand Content
{
"id": "INTERACTION_ID",
"status": "in_progress",
"object": "interaction"
}
INTERACTION_ID 取得放大影片:
使用任何要求資料之前,請先修改下列項目的值:
-
PROJECT_ID:代表 Google Cloud 專案 ID 的字串。 -
INTERACTION_ID:要求中的互動 ID。
HTTP 方法和網址:
GET https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID
如要傳送要求,請選擇以下其中一個選項:
curl
執行下列指令:
curl -X GET \
-H "Authorization: Bearer TOKEN" \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID"
PowerShell
執行下列指令:
$headers = @{ "Authorization" = "Bearer TOKEN" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID" | Select-Object -Expand Content
{
"id":"INTERACTION_ID",
"model":"gemini-omni-1.2-flash",
"status":"completed",
"usage":{
"total_tokens":29435,
"total_input_tokens":150,
"input_tokens_by_modality":[
{
"modality":"text",
"tokens":26
},
{
"modality":"image",
"tokens":124
}
],
"output_tokens_by_modality": [
{
"modality": "video",
"tokens": 28832
}
],
"total_output_tokens":28832,
"total_thought_tokens":453
},
"steps":[
{
"type": "user_input",
"content": [
{
"type": "text",
"text": "5 second, 9:16 video. Use the image as the first frame."
},
{
"type": "image",
"uri": "gs://some/path",
"mime_type": "image/png"
}
]
},
{
"type":"thought",
"summary":[
{
"type":"text",
"text":"MODEL THOUGHTS"
}
]
},
{
"type":"model_output",
"content":[
{
"type":"video",
"uri":"gs://some/output_path/123.mp4",
"mime_type":"video/mp4"
}
]
}
],
"object":"interaction",
"role":"model",
"created":"2026-05-29T02:17:56Z",
"updated":"2026-05-29T02:17:56Z"
}
使用內嵌傳送時 ("delivery": "inline",省略 gcs_uri),model_output 步驟會傳回完整影片,做為 steps[].content[].data 中 "mime_type": "video/mp4" 旁的 Base64 編碼位元組字串,而非 uri:
{
"type": "model_output",
"content": [
{
"type": "video",
"data": "BASE64_ENCODED_VIDEO",
"mime_type": "video/mp4"
}
]
}