This documentation page is also available as an interactive notebook. You can launch the notebook in
Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
above links.
Create videos from text prompts or animate images using Google’s Gemini
Omni model.
Problem
You need to generate video content programmatically for social media,
product demos, or creative applications.
Solution
What’s in this recipe:
Generate videos from text prompts
Animate existing images into videos
Store prompts and generated videos together
You generate videos with Google’s Gemini Omni model. Computed columns
store each generated video with its prompt. Updating the prompt
regenerates that row’s video.
Setup
%pip install -qU pixeltable "google-genai>=2.22"
import getpassimport osif 'GEMINI_API_KEY' not in os.environ: os.environ['GEMINI_API_KEY'] = getpass.getpass( 'Google AI Studio API Key: ' )
import pixeltable as pxtfrom pixeltable.functions import gemini# Create a fresh directorypxt.drop_dir('video_gen_demo', force=True)pxt.create_dir('video_gen_demo')
Created directory ‘video_gen_demo’.
<pixeltable.catalog.dir.Dir at 0x12d80c190>
Generate videos from text prompts
# Create a table for text-to-video generationvideos = pxt.create_table( 'video_gen_demo/text_to_video', {'prompt': pxt.String})# Add computed column that generates videosvideos.add_computed_column( video=gemini.generate_video( videos.prompt, model='gemini-omni-1.1-flash', config={'aspect_ratio': '16:9', 'resolution': '720p'}, ))
Created table ‘text_to_video’.
Added 0 column values with 0 errors in 0.00 s
No rows affected.
# Generate a video from a text promptvideos.insert( [ { 'prompt': 'A serene mountain lake at sunrise with mist rising from the water' } ])# View the resultvideos.select(videos.prompt, videos.video).collect()
Inserted 1 row with 0 errors in 48.38 s (0.02 rows/s)
Animate images into videos
# Create a table for image-to-video generationanimated = pxt.create_table( 'video_gen_demo/image_to_video', {'image': pxt.Image, 'description': pxt.String},)# Add computed column that animates imagesanimated.add_computed_column( video=gemini.generate_video( animated.description, images=[animated.image], model='gemini-omni-1.1-flash', config={'aspect_ratio': '9:16', 'resolution': '720p'}, ))
Created table ‘image_to_video’.
Added 0 column values with 0 errors in 0.00 s
No rows affected.
# Animate an imagebase_url = 'https://raw.githubusercontent.com/pixeltable/pixeltable/main/docs/resources/images'animated.insert( [ { 'image': f'{base_url}/000000000030.jpg', 'description': 'Beach scene.', } ])# View the animated resultanimated.select(animated.image, animated.video).collect()
Inserted 1 row with 0 errors in 37.17 s (0.03 rows/s)
Explanation
Generation modes:Gemini Omni model:Tips:
Prompts work best when descriptive and specific
Computed columns store generated videos; reading them does not repeat
generation
The prompt describes how to animate the reference images
New rows automatically generate videos on insert
Requirements:
Google AI Studio API key (set GEMINI_API_KEY); Gemini Omni requires
the Gemini Developer API