You can use Veo on Vertex AI to remove objects from videos that you generate. You
provide a mask and a video object, and then use a text prompt to describe the
output that you want. The Vertex AI API is supported during Preview.
Supported interfaces include the Google Cloud console and the Vertex AI
API.
For more information about writing effective text prompts for video generation,
see theVeo prompt
guide.
Sign in to your Google Cloud account. If you're new to
Google Cloud,create an accountto evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
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
(roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant
roles.
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which
contains theserviceusage.services.enablepermission.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
(roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant
roles.
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which
contains theserviceusage.services.enablepermission.Learn how to grant
roles.
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
Python
To use the Python samples on this page in a local
development environment, install and initialize the gcloud CLI, and
then set up Application Default Credentials with your user credentials.
Optional: In theSettingspane, configure the following settings:
Model: chooseVeo 2 Preview.
Aspect ratio: choose either16:9or9:16.
Number of results: adjust the slider or enter a value between1and4.
Video length: select the video length that you want from the menu.
Output directory: clickBrowseto create or select aCloud Storage bucketto store output files.
Optional: In theSafetysection, select one of the followingPerson
generationsettings:
Allow (Adults only): default value. Generate adult people or faces
only. Don't generate youth or children people or faces.
Don't allow: don't generate people or faces.
Optional: In theAdvanced optionssection, enter aSeedvalue for
randomizing video generation.
Clickupload an image or video.
Choose a local video to upload and clickSelect.
Do one of the following:
Upload your own mask:
Create a mask on your computer.
ClickUpload mask. In the displayed dialog, select a mask to
upload.
Define your mask:in the editing toolbar, use the mask tools
(check_box_outline_blankbox,brushbrush, ormasked_transitionsinvert
tool) to specify the area or areas to add content to.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values# with appropriate values for your project.exportGOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECTexportGOOGLE_CLOUD_LOCATION=globalexportGOOGLE_GENAI_USE_VERTEXAI=True
importtimefromgoogleimportgenaifromgoogle.genai.typesimportGenerateVideosSource,GenerateVideosConfig,Image,Video,VideoGenerationMask,VideoGenerationMaskModeclient=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-2.0-generate-preview",source=GenerateVideosSource(video=Video(uri="gs://cloud-samples-data/generative-ai/video/truck.mp4",mime_type="video/mp4")),config=GenerateVideosConfig(mask=VideoGenerationMask(image=Image(gcs_uri="gs://cloud-samples-data/generative-ai/image/truck-inpainting-dynamic-mask.png",mime_type="image/png",),mask_mode=VideoGenerationMaskMode.REMOVE,),output_gcs_uri=output_gcs_uri,),)whilenotoperation.done:time.sleep(15)operation=client.operations.get(operation)print(operation)ifoperation.response:print(operation.result.generated_videos[0].video.uri)# Example response:# gs://your-bucket/your-prefix
REST
After youset up your environment,
you can use REST to test a text prompt. The following sample sends a request to the publisher
model endpoint.
Use the following command to send a video generation request. This request
begins a long-running operation and stores output to a Cloud Storage
bucket you specify.
Before using any of the request data,
make the following replacements:
PROJECT_ID: Your
Google Cloud project ID.
TEXT_PROMPT: The text prompt
used to guide video generation.
MASK_STORAGE_URIThe Cloud Storage bucket URI path to the mask object.
MASK_MIME_TYPEThe MIME type
of the image mask. Only one of the following:
image/png
image/jpeg
image/webp
VIDEO_INPUT_STORAGE_URIThe Cloud Storage bucket URI path video input object.
VIDEO_MIME_TYPEThe MIME
type of the video object. Only one of the following:
video/mov
video/mpeg
video/mp4
video/mpg
video/avi
video/wmv
video/mpegps
video/flv
OUTPUT_STORAGE_URI:
Optional: The Cloud Storage bucket to store the output videos. If not
provided, a Base64-bytes encoded video is returned in the response. For
example:gs://video-bucket/output/.
RESPONSE_COUNT: The number of
video files you want to generate. Accepted integer values: 1-4.
Additional optional parameters
Use the following optional variables depending on your use
case. Add some or all of the following parameters in the"parameters": {}object.
ASPECT_RATIO:
Optional: A string value that describes the aspect ratio of the generated
videos. You can use the following values:
"16:9"for landscape
"9:16"for portrait
The default value is"16:9"
NEGATIVE_PROMPT: Optional: A string
value that describes content that you want to prevent the model from
generating.
PERSON_SAFETY_SETTING:
Optional: A string value that controls the safety setting for generating
people or face generation. You can use the following values:
"allow_adult": Only allow generation of adult people and
faces.
"disallow": Doesn't generate people or faces.
The default value is"allow_adult".
RESOLUTION:
Optional: A string value that controls the resolution of the generated
video. Supported byVeo 3 models only.You can use the following
values:
"720p"
"1080p"
The default value is"720p".
RESPONSE_COUNT:
Optional. An integer value that describes the number of videos to generate.
The accepted range of values is1-4.
SEED_NUMBER:
Optional. An uint32 value that the model uses to generate deterministic
videos. Specifying a seed number with your request without changing other
parameters guides the model to produce the same videos. The accepted range
of values is0-4294967295.
HTTP method and URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/veo-2.0-generate-preview:predictLongRunning
Request JSON body:
{
"instances": [
{
"prompt": "TEXT_PROMPT",
// The following fields can be repeated for up to three total
// images.
"mask": {
"gcsUri": "MASK_STORAGE_URI",
"mimeType": "MASK_MIME_TYPE",
"maskMode": "remove"
},
"video": {
"gcsUri": "VIDEO_INPUT_STORAGE_URI",
"mimeType": "VIDEO_MIME_TYPE"
}
}
],
"parameters": {
"storageUri": "OUTPUT_STORAGE_URI",
"sampleCount":RESPONSE_COUNT,
}
}
To send your request, choose one of these options:
curl
Save the request body in a file namedrequest.json,
and execute the following command:
This request returns a full operation name with a unique operation ID. Use this
full operation name to poll that status of the video generation request.
OPERATION_ID: The unique operation ID returned in the original generate video
request.
HTTP method and URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:fetchPredictOperation
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]