根据文本提示生成视频

您可以使用 Gemini Enterprise Agent Platform 上的 Gemini Omni Flash 或 Veo 根据文本提示生成新视频。支持的界面包括 Google Cloud 控制台和 Agent Platform API。

以下模型支持根据文本提示生成视频:

Gemini Omni Flash

点击即可展开支持的型号

Veo

点击即可展开支持的型号

如需详细了解如何编写有效的文本提示来生成视频,请参阅视频生成提示指南

在 Colab 中试用 Gemini Omni Flash

在 Colab 中试用 Veo

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud新手,请 创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Enable the Agent Platform API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  4. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  5. Enable the Agent Platform API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  6. 为您的环境设置身份验证。

    选择标签页以了解您打算如何使用本页面上的示例:

    控制台

    当您使用 Google Cloud 控制台访问 Google Cloud 服务和 API 时,无需设置身份验证。

    REST

    如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 gcloud CLI 的凭证。

      安装 Google Cloud CLI。

      如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI

    如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证

使用 Gemini Omni Flash 生成视频

如需使用 Gemini Omni Flash 生成视频,请执行以下操作:

REST

如需详细了解如何使用 Gemini Omni Flash API,请参阅Interactions API

生成视频可能需要超过一分钟才能完成。如需生成视频并在完成后立即下载,请使用同步请求。如需生成可供日后下载的视频,请将 background 参数设置为 true,以发送异步请求。异步互动内容最多可保留 14 天。

同步请求

在使用任何请求数据之前,请先进行以下替换:

  • PROJECT_ID:表示您的 Google Cloud 项目 ID 的字符串。
  • MODEL_ID:表示要使用的模型 ID 的字符串。接受的值如下:
    • "gemini-omni-flash-preview"
  • TEXT_PROMPT:用于指导视频生成的文本提示。
  • CLOUD_STORAGE_OUTPUT_URI:可选:一个字符串,表示用于存储输出视频的 Cloud Storage 存储桶。如果未提供,则回答中会返回视频字节。 例如:"gs://video-bucket/output/"
  • ASPECT_RATIO:(可选)一个字符串,表示输出视频的预期宽高比。如果未提供,则系统会根据提示推断宽高比。 接受的值如下:
    • "16:9"
    • "9:16"
  • DURATION:一个字符串,表示生成的视频文件的时长。允许的字符串是介于 310 之间的整数,后跟“s”表示秒。例如,"10s"

HTTP 方法和网址:

POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions

请求 JSON 正文:

{
  "model": "MODEL_ID",
  "input": [
    {
      "type": "text",
      "text": "TEXT_PROMPT"
    }
  ],
  "response_format": [
    {
      "type": "video",
      "delivery": "uri",
      "gcs_uri": "CLOUD_STORAGE_OUTPUT_URI",
      "aspect_ratio": "ASPECT_RATIO",
      "duration": "DURATION"
    }
  ],
  "generation_config": {
    "video_config": {
      "task": "text_to_video"
    }
  }
}

如需发送请求,请选择以下方式之一:

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-flash-preview",
  "status":"completed",
  "usage":{
    "total_tokens":479,
    "total_input_tokens":26,
    "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":"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",
}

异步请求

在使用任何请求数据之前,请先进行以下替换:

  • PROJECT_ID:表示您的 Google Cloud 项目 ID 的字符串。
  • MODEL_ID:表示要使用的模型 ID 的字符串。接受的值如下:
    • "gemini-omni-flash-preview"
  • TEXT_PROMPT:用于指导视频生成的文本提示。
  • CLOUD_STORAGE_OUTPUT_URI:可选:一个字符串,表示用于存储输出视频的 Cloud Storage 存储桶。如果未提供,则回答中会返回视频字节。 例如:"gs://video-bucket/output/"
  • ASPECT_RATIO:(可选)一个字符串,表示输出视频的预期宽高比。如果未提供,则系统会根据提示推断宽高比。 接受的值如下:
    • "16:9"
    • "9:16"
  • DURATION:一个字符串,表示生成的视频文件的时长。允许的字符串是介于 310 之间的整数,后跟“s”表示秒。例如,"10s"

HTTP 方法和网址:

POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions

请求 JSON 正文:

{
  "model": "MODEL_ID",
  "input": [
    {
      "background": true,
      "type": "text",
      "text": "TEXT_PROMPT"
    }
  ],
  "response_format": [
    {
      "type": "video",
      "delivery": "uri",
      "gcs_uri": "CLOUD_STORAGE_OUTPUT_URI",
      "aspect_ratio": "ASPECT_RATIO",
      "duration": "DURATION"
    }
  ],
  "generation_config": {
    "video_config": {
      "task": "text_to_video"
    }
  }
}

如需发送请求,请选择以下方式之一:

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,您将使用该 ID 获取生成的视频。
{
  "id":"INTERACTION_ID",
  "status":"in_progress",
  "object":"interaction"
}
稍后,使用 INTERACTION_ID 获取生成的视频:

在使用任何请求数据之前,请先进行以下替换:

  • PROJECT_ID:表示您的 Google Cloud 项目 ID 的字符串。
  • INTERACTION_ID:异步请求中的互动 ID。

HTTP 方法和网址:

POST https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID

如需发送请求,请选择以下方式之一:

curl

执行以下命令:

curl -X POST \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/global/interactions/INTERACTION_ID"

PowerShell

执行以下命令:

$headers = @{ "Authorization" = "Bearer TOKEN" }

Invoke-WebRequest `
-Method POST `
-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-flash-preview",
  "status":"completed",
  "usage":{
    "total_tokens":479,
    "total_input_tokens":26,
    "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",
          "data":"VIDEO DATA",
          "mime_type":"video/mp4" 
        }
      ]
    }
  ],
  "object":"interaction"
  "role":"model",
  "created":"2026-05-29T02:17:56Z",
  "updated":"2026-05-29T02:17:56Z",
}

使用 Veo 生成视频

以下示例展示了如何使用 Veo 通过文本提示生成视频:

控制台

  1. 在 Google Cloud 控制台中,依次前往 Agent Platform > Media Studio 页面。

    Media Studio

  2. 点击视频

  3. 任务菜单中,选择文字转视频

  4. 模型菜单中,从显示的选项中选择一个模型。

  5. 提示框中,输入描述要生成的视频的文本提示。

  6. 可选:调整以下参数

    • 宽高比:选择 16:99:16

    • 结果数量:调整滑块或输入介于 14 之间的值。

    • 视频时长:从菜单中选择视频时长。

    • 输出目录:点击浏览以创建或选择一个 Cloud Storage 存储桶来存储生成的文件。

  7. 点击运行

Python

安装

pip install --upgrade google-genai

如需了解详情,请参阅 SDK 参考文档

设置环境变量以将 Google Gen AI SDK 与 Vertex AI 搭配使用:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

import time
from google import genai
from google.genai.types import GenerateVideosConfig

client = genai.Client()

# TODO(developer): Update and un-comment below line
# output_gcs_uri = "gs://your-bucket/your-prefix"

operation = client.models.generate_videos(
    model="veo-3.1-generate-001",
    prompt="a cat reading a book",
    config=GenerateVideosConfig(
        aspect_ratio="16:9",
        output_gcs_uri=output_gcs_uri,
    ),
)

while not operation.done:
    time.sleep(15)
    operation = client.operations.get(operation)
    print(operation)

if operation.response:
    print(operation.result.generated_videos[0].video.uri)

# Example response:
# gs://your-bucket/your-prefix

Go

了解如何安装或更新 Go

如需了解详情,请参阅 SDK 参考文档

设置环境变量以将 Google Gen AI SDK 与 Vertex AI 搭配使用:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

import (
	"context"
	"fmt"
	"io"
	"time"

	"google.golang.org/genai"
)

// generateVideoWithText shows how to gen video from text.
func generateVideoWithText(w io.Writer, outputGCSURI string) error {
	//outputGCSURI = "gs://your-bucket/your-prefix"
	ctx := context.Background()

	client, err := genai.NewClient(ctx, &genai.ClientConfig{
		HTTPOptions: genai.HTTPOptions{APIVersion: "v1"},
	})
	if err != nil {
		return fmt.Errorf("failed to create genai client: %w", err)
	}

	config := &genai.GenerateVideosConfig{
		AspectRatio:  "16:9",
		OutputGCSURI: outputGCSURI,
	}

	modelName := "veo-3.0-generate-preview"
	prompt := "a cat reading a book"
	operation, err := client.Models.GenerateVideos(ctx, modelName, prompt, nil, config)
	if err != nil {
		return fmt.Errorf("failed to start video generation: %w", err)
	}

	// Polling until the operation is done
	for !operation.Done {
		time.Sleep(15 * time.Second)
		operation, err = client.Operations.GetVideosOperation(ctx, operation, nil)
		if err != nil {
			return fmt.Errorf("failed to get operation status: %w", err)
		}
	}

	if operation.Response != nil && len(operation.Response.GeneratedVideos) > 0 {
		videoURI := operation.Response.GeneratedVideos[0].Video.URI
		fmt.Fprintln(w, videoURI)
		return nil
	}

	// Example response:
	// gs://your-bucket/your-prefix/videoURI

	return fmt.Errorf("video generation failed or returned no results")
}

Node.js

安装

npm install @google/genai

如需了解详情,请参阅 SDK 参考文档

设置环境变量以将 Google Gen AI SDK 与 Vertex AI 搭配使用:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True

const {GoogleGenAI} = require('@google/genai');

const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT;
const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global';

async function generateVideo(
  outputGcsUri,
  projectId = GOOGLE_CLOUD_PROJECT,
  location = GOOGLE_CLOUD_LOCATION
) {
  const client = new GoogleGenAI({
    vertexai: true,
    project: projectId,
    location: location,
  });

  let operation = await client.models.generateVideos({
    model: 'veo-3.1-fast-generate-001',
    prompt: 'a cat reading a book',
    config: {
      aspectRatio: '16:9',
      outputGcsUri: outputGcsUri,
    },
  });

  while (!operation.done) {
    await new Promise(resolve => setTimeout(resolve, 15000));
    operation = await client.operations.get({operation: operation});
    console.log(operation);
  }

  if (operation.response) {
    console.log(operation.response.generatedVideos[0].video.uri);
  }
  return operation;
}

Java

了解如何安装或更新 Java

如需了解详情,请参阅 SDK 参考文档

设置环境变量以将 Google Gen AI SDK 与 Vertex AI 搭配使用:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_ENTERPRISE=True


import com.google.genai.Client;
import com.google.genai.types.GenerateVideosConfig;
import com.google.genai.types.GenerateVideosOperation;
import com.google.genai.types.GenerateVideosResponse;
import com.google.genai.types.GenerateVideosSource;
import com.google.genai.types.GeneratedVideo;
import com.google.genai.types.GetOperationConfig;
import com.google.genai.types.Video;
import java.util.concurrent.TimeUnit;

public class VideoGenWithTxt {

  public static void main(String[] args) throws InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String modelId = "veo-3.1-generate-001";
    String outputGcsUri = "gs://your-bucket/your-prefix";
    generateContent(modelId, outputGcsUri);
  }

  // Generates a video with a text prompt.
  public static String generateContent(String modelId, String outputGcsUri)
      throws InterruptedException {
    // Client Initialization. Once created, it can be reused for multiple requests.
    try (Client client = Client.builder().location("global").vertexAI(true).build()) {

      GenerateVideosOperation operation =
          client.models.generateVideos(
              modelId,
              GenerateVideosSource.builder().prompt("a cat reading a book").build(),
              GenerateVideosConfig.builder()
                  .aspectRatio("16:9")
                  .outputGcsUri(outputGcsUri)
                  .build());

      while (!operation.done().orElse(false)) {
        TimeUnit.SECONDS.sleep(15);
        operation =
            client.operations.getVideosOperation(operation, GetOperationConfig.builder().build());
      }

      String generatedVideoUri =
          operation
              .response()
              .flatMap(GenerateVideosResponse::generatedVideos)
              .flatMap(videos -> videos.stream().findFirst())
              .flatMap(GeneratedVideo::video)
              .flatMap(Video::uri)
              .orElseThrow(
                  () ->
                      new IllegalStateException(
                          "Could not get the URI from the generated video"));

      System.out.println("Generated video URI: " + generatedVideoUri);
      // Example response:
      // Generated video URI: gs://your-bucket/your-prefix/generated-video-123.mp4
      return generatedVideoUri;
    }
  }
}

REST

如需详细了解 Veo API,请参阅以下内容:

  1. 使用以下命令发送视频生成请求。此请求会启动长时间运行的操作,并将输出存储到您指定的 Cloud Storage 存储桶。

    在使用任何请求数据之前,请先进行以下替换:

    • PROJECT_ID:表示您的 Google Cloud 项目 ID 的字符串。
    • MODEL_ID:表示要使用的模型 ID 的字符串。接受的值如下:
      • Veo 2: "veo-2.0-generate-001"
      • Veo 3:"veo-3.0-generate-001"
      • Veo 3:"veo-3.0-fast-generate-001"
      • Veo 3:"veo-3.0-generate-preview"(预览版)
      • Veo 3:"veo-3.0-fast-generate-preview"(预览版)
      • Veo 3.1: "veo-3.1-generate-001"
      • Veo 3.1: "veo-3.1-fast-generate-001"
    • TEXT_PROMPT:用于指导视频生成的文本提示。
    • OUTPUT_STORAGE_URI:(可选)一个字符串,表示用于存储输出视频的 Cloud Storage 存储桶。如果未提供,则回答中会返回视频字节。例如:"gs://video-bucket/output/"
    • RESPONSE_COUNT:要生成的视频文件数量。可接受的值范围为 1-4
    • DURATION:一个整数,表示生成的视频文件的时长。以下是每种模型接受的值:
      • Veo 2 模型:5-8。默认值为 8
      • Veo 3 模型:468。默认为 8
    • 其他可选参数

      根据您的应用场景,使用以下可选变量。在 "parameters": {} 对象中添加以下部分或全部参数。

      "parameters": {
        "aspectRatio": "ASPECT_RATIO",
        "negativePrompt": "NEGATIVE_PROMPT",
        "personGeneration": "PERSON_SAFETY_SETTING",
        // "resolution": RESOLUTION, // Veo 3 models only
        "sampleCount": RESPONSE_COUNT,
        "seed": SEED_NUMBER
      }
      • ASPECT_RATIO:(可选)一个字符串值,用于描述所生成视频的宽高比。您可使用以下值:
        • "16:9" 表示横向
        • "9:16" 表示纵向

        默认值为 "16:9"

      • NEGATIVE_PROMPT:(可选)一个字符串值,用于描述您想要阻止模型生成的内容。
      • PERSON_SAFETY_SETTING:(可选)一个字符串值,用于控制生成人物或人脸的安全设置。您可使用以下值:
        • "allow_adult":仅允许生成成人形象和人脸。
        • "disallow":不生成人物或人脸。

        默认值为 "allow_adult"

      • RESOLUTION:(可选)用于控制生成的视频分辨率的字符串值。仅受 Veo 3 模型支持。您可使用以下值:
        • "720p"
        • "1080p"
        • "4k"(仅限 Veo 3.1 预览版模型)

        默认值为 "720p"

      • RESPONSE_COUNT:可选。一个整数值,用于描述要生成的视频数量。可接受的值范围为 1-4
      • SEED_NUMBER:可选。一个 uint32 值,模型使用该值生成确定性视频。通过在请求中指定种子编号而无需更改其他参数,可引导模型生成相同的视频。可接受的值范围为 0-4294967295

    HTTP 方法和网址:

    POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:predictLongRunning

    请求 JSON 正文:

    {
      "instances": [
        {
          "prompt": "TEXT_PROMPT"
        }
      ],
      "parameters": {
        "storageUri": "OUTPUT_STORAGE_URI",
        "sampleCount": "RESPONSE_COUNT"
      }
    }
    

    如需发送请求,请选择以下方式之一:

    curl

    将请求正文保存在名为 request.json 的文件中,然后执行以下命令:

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:predictLongRunning"

    PowerShell

    将请求正文保存在名为 request.json 的文件中,然后执行以下命令:

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:predictLongRunning" | Select-Object -Expand Content
    此请求会返回包含唯一操作 ID 的完整操作名称。使用此完整操作名称轮询视频生成请求的状态。
    {
      "name": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/a1b07c8e-7b5a-4aba-bb34-3e1ccb8afcc8"
    }
    

  2. 可选:检查长时间运行的视频生成操作的状态。

    在使用任何请求数据之前,请先进行以下替换:

    • PROJECT_ID:您的 Google Cloud 项目 ID
    • MODEL_ID:要使用的模型 ID。
    • OPERATION_ID:在原始生成视频请求中返回的唯一操作 ID。

    HTTP 方法和网址:

    POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:fetchPredictOperation

    请求 JSON 正文:

    {
      "operationName": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/OPERATION_ID"
    }
    

    如需发送请求,请选择以下方式之一:

    curl

    将请求正文保存在名为 request.json 的文件中,然后执行以下命令:

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:fetchPredictOperation"

    PowerShell

    将请求正文保存在名为 request.json 的文件中,然后执行以下命令:

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:fetchPredictOperation" | Select-Object -Expand Content
    此请求会返回有关操作的信息,包括操作是否仍在运行或已完成。

后续步骤