Generate Videos from Images using Veo

Create videos from images, using Veo , a generative AI model for video generation.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Python

Before trying this sample, follow the Python setup instructions in the Vertex AI quickstart using client libraries . For more information, see the Vertex AI Python API reference documentation .

To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment .

  import 
  
 time 
 from 
  
 google 
  
 import 
 genai 
 from 
  
 google.genai.types 
  
 import 
 GenerateVideosConfig 
 , 
 Image 
 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.0-generate-preview" 
 , 
 prompt 
 = 
 "Extreme close-up of a cluster of vibrant wildflowers swaying gently in a sun-drenched meadow." 
 , 
 image 
 = 
 Image 
 ( 
 gcs_uri 
 = 
 "gs://cloud-samples-data/generative-ai/image/flowers.png" 
 , 
 mime_type 
 = 
 "image/png" 
 , 
 ), 
 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 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: