Veo 是支持生成视频的模型的名称。Veo 会根据您提供的文本提示或图片提示生成视频。
如需在控制台中浏览此模型,请参阅模型库中的 Video Generation
模型卡片。
试用 Veo on Vertex AI (Vertex AI Studio)
支持的模型
Veo API 支持以下模型:
HTTP 请求
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://LOCATION}-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_ID:predictLongRunning \
-d '{
"instances": [
{
"prompt": string,
// Optional. An image to guide video generation.
"image": {
// Union field can be only one of the following:
"bytesBase64Encoded": string,
"gcsUri": string,
// End of list of possible types for union field.
"mimeType": string
}
}
],
"parameters": {
"aspectRatio": string,
"negativePrompt": string,
"personGeneration": string,
"sampleCount": integer,
"seed": uint32,
"storageUri": string,
"durationSeconds": integer,
"enhancePrompt": boolean
}
}'
对 Veo 模型使用以下参数。如需了解详情,请参阅使用 Veo 通过文本和图片提示生成视频。
参数 | |
---|---|
|
文本转视频功能需要此权限。 一个文本字符串,用于引导视频的前八秒。例如:
|
|
图片转视频功能需要此权限。 用于指导视频生成的输入图片。建议使用 1280 x 720 像素或 720 x 1280 像素的图片。 以下项之一:
如果图片的宽高比不同,系统会使用中心裁剪工具对图片进行裁剪。 如果图片的宽高比相同但分辨率更高,系统会调整图片大小。 |
durationSeconds |
必需。您要生成的视频文件的长度。
接受的整数值为 |
negativePrompt |
可选。一个文本字符串,用于描述您想要阻止模型生成的内容。例如:
|
enhancePrompt |
可选。使用 Gemini 优化问题。可接受的值为 |
seed |
可选。请求的数字,以使生成的视频具有确定性。在请求中添加种子编号而不更改其他参数会导致模型生成相同的视频。
接受的范围为 |
storageURI |
可选。用于存储输出视频的 Cloud Storage 存储桶 URI,格式为 |
sampleCount |
可选。请求的输出图片数量。接受的值为 |
aspectRatio |
可选。定义所生成视频的宽高比。以下任一情况:
|
personGeneration |
可选。用于控制是否允许人物或人脸生成的安全设置。以下任一项:
|
generateAudio |
|
示例请求
使用以下请求发送文本转视频请求或图片转视频请求:
文本转视频生成请求
REST
如需使用 Vertex AI Veo API 测试文本提示,请向发布方模型端点发送 POST 请求。
在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的 Google Cloud 项目 ID。
- MODEL_ID:要使用的模型 ID。可用的值:
veo-2.0-generate-001
(GA 许可名单)veo-3.0-generate-preview
(预览版)
- TEXT_PROMPT:用于指导视频生成的文本提示。
- OUTPUT_STORAGE_URI:可选:用于存储输出视频的 Cloud Storage 存储桶。如果未提供,则回答中会返回视频字节。例如:
gs://video-bucket/output/
- RESPONSE_COUNT:您要生成的视频文件数量。接受的整数值:1-4。
- DURATION:您要生成的视频文件的长度。接受的整数值为 5-8。
-
其他可选参数
根据您的应用场景,使用以下可选变量。在
"parameters": {}
对象中添加以下部分或全部参数。"parameters": { "aspectRatio": "ASPECT_RATIO", "negativePrompt": "NEGATIVE_PROMPT", "personGeneration": "PERSON_SAFETY_SETTING", "sampleCount": RESPONSE_COUNT, "seed": SEED_NUMBER }
- ASPECT_RATIO:字符串。可选。定义所生成视频的宽高比。值:
16:9
(默认,横向)或9:16
(纵向)。 - NEGATIVE_PROMPT:字符串。可选。用于描述您想要阻止模型生成的内容的文本字符串。
- PERSON_SAFETY_SETTING:字符串。可选。用于控制是否允许人物或人脸生成的安全设置。值:
allow_adult
(默认值):仅允许生成成年人。disallow
:禁止在图片中包含人物或人脸。
- RESPONSE_COUNT:int。可选。请求的输出图片数量。值:
1
-4
。 - SEED_NUMBER:uint32。可选。用于使生成的视频具有确定性的数字。通过在请求中指定种子编号而无需更改其他参数,可引导模型生成相同的视频。值:
0
-4294967295
。
- ASPECT_RATIO:字符串。可选。定义所生成视频的宽高比。值:
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
{ "name": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/a1b07c8e-7b5a-4aba-bb34-3e1ccb8afcc8" }
图片转视频生成请求
REST
如需使用 Vertex AI Veo API 测试文本提示,请向发布方模型端点发送 POST 请求。
在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的 Google Cloud 项目 ID。
- MODEL_ID:要使用的模型 ID。可用的值:
veo-2.0-generate-001
(GA 许可名单)veo-3.0-generate-preview
(预览版)
- TEXT_PROMPT:用于指导视频生成的文本提示。
- INPUT_IMAGE:表示输入图片的 base64 编码字节串。为确保质量,输入图片应为 720p 或更高(1280 x 720 像素),宽高比应为 16:9 或 9:16。其他宽高比或尺寸的图片可能会在上传过程中调整大小或进行中心剪裁。
- MIME_TYPE:输入图片的 MIME 类型。仅支持以下 MIME 类型的图片:
image/jpeg
或image/png
。 - OUTPUT_STORAGE_URI:可选:用于存储输出视频的 Cloud Storage 存储桶。如果未提供,则回答中会返回视频字节。例如:
gs://video-bucket/output/
- RESPONSE_COUNT:您要生成的视频文件数量。接受的整数值:1-4。
- DURATION:您要生成的视频文件的长度。接受的整数值为 5-8。
-
其他可选参数
根据您的应用场景,使用以下可选变量。在
"parameters": {}
对象中添加以下部分或全部参数。"parameters": { "aspectRatio": "ASPECT_RATIO", "negativePrompt": "NEGATIVE_PROMPT", "personGeneration": "PERSON_SAFETY_SETTING", "sampleCount": RESPONSE_COUNT, "seed": SEED_NUMBER }
- ASPECT_RATIO:字符串。可选。定义所生成视频的宽高比。值:
16:9
(默认,横向)或9:16
(纵向)。 - NEGATIVE_PROMPT:字符串。可选。用于描述您想要阻止模型生成的内容的文本字符串。
- PERSON_SAFETY_SETTING:字符串。可选。用于控制是否允许人物或人脸生成的安全设置。值:
allow_adult
(默认值):仅允许生成成年人。disallow
:禁止在图片中包含人物或人脸。
- RESPONSE_COUNT:int。可选。请求的输出图片数量。值:
1
-4
。 - SEED_NUMBER:uint32。可选。用于使生成的视频具有确定性的数字。通过在请求中指定种子编号而无需更改其他参数,可引导模型生成相同的视频。值:
0
-4294967295
。
- ASPECT_RATIO:字符串。可选。定义所生成视频的宽高比。值:
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", "image": { "bytesBase64Encoded": "INPUT_IMAGE", "mimeType": "MIME_TYPE" } } ], "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
{ "name": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/a1b07c8e-7b5a-4aba-bb34-3e1ccb8afcc8" }
轮询视频生成长时间运行操作的状态
检查视频生成长时间运行操作的状态。
REST
在使用任何请求数据之前,请先进行以下替换:
- PROJECT_ID:您的 Google Cloud 项目 ID。
- MODEL_ID:要使用的模型 ID。可用的值:
veo-2.0-generate-001
(GA 许可名单)veo-3.0-generate-preview
(预览版)
- 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
回答正文(生成视频请求)
发送文本转视频或图片转视频请求会返回以下回答:
{
"name": string
}
回答元素 | 说明 |
---|---|
name |
在发送视频生成请求后开始的长时间运行操作的完整操作名称。 |
示例回答(生成视频请求)
{
"name": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/OPERATION_ID"
}
回答正文(轮询长时间运行的操作)
轮询原始视频生成长时间运行操作的状态会返回以下回答:
{
"name": string,
"done": boolean,
"response":{
"@type":"type.googleapis.com/cloud.ai.large_models.vision.GenerateVideoResponse",
"generatedSamples":[
{
"video":
{
"uri": string,
"encoding": string
}
},
{
"video":
{
"uri": string,
"encoding": string
}
},
{
"video":
{
"uri": string,
"encoding": string
}
},
{
"video":
{
"uri": string,
"encoding": string
}
},
]
}
}
回答元素 | 说明 |
---|---|
name |
在发送视频生成请求后开始的长时间运行操作的完整操作名称。 |
done |
一个布尔值,指示操作是否已完成。 |
response |
长时间运行的操作的回答正文。 |
generatedSamples |
生成的视频示例对象的数组。 |
video |
生成的视频。 |
uri |
生成的视频的 Cloud Storage URI。 |
encoding |
视频编码类型。 |
示例回答(轮询长时间运行的操作)
{
"name": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/OPERATION_ID",
"done":true,
"response":{
"@type":"type.googleapis.com/cloud.ai.large_models.vision.GenerateVideoResponse",
"generatedSamples":[
{
"video":{
"uri":"gs://STORAGE_BUCKET/TIMESTAMPED_SUBDIRECTORY/sample_0.mp4",
"encoding":"video/mp4"
}
},
{
"video":{
"uri":"gs://STORAGE_BUCKET/TIMESTAMPED_SUBDIRECTORY/sample_1.mp4",
"encoding":"video/mp4"
}
},
{
"video":{
"uri":"gs://STORAGE_BUCKET/TIMESTAMPED_SUBDIRECTORY/sample_2.mp4",
"encoding":"video/mp4"
}
},
{
"video":{
"uri":"gs://STORAGE_BUCKET/TIMESTAMPED_SUBDIRECTORY/sample_3.mp4",
"encoding":"video/mp4"
}
}
]
}
}
更多信息
- 如需详细了解如何在 Vertex AI 中使用 Veo,请参阅使用 Veo 通过文本和图片提示生成视频。
后续步骤
- 阅读 Google DeepMind 关于 Veo 模型的信息。
- 阅读博文“Veo 和 Imagen 3:正式推出 Vertex AI 上的新视频和图片生成模型”。
- 阅读博文“与创作者一起为创作者打造的全新生成式媒体模型和工具”。