feat(py): add veo 3.x googleai support#5125
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for Google AI Veo 3.0 and 3.1 models, including new configuration fields for resolution and seed. The changes include updates to the model enums, configuration schemas, and the addition of specific video generation flows in the sample application. Review feedback suggests improving the sample code by using Pydantic model inheritance to reduce duplication, utilizing model_dump for more efficient configuration dictionary creation, and setting the default resolution to null to ensure compatibility across different model versions.
I am having trouble creating individual review comments. Click here to see my feedback.
py/samples/google-genai-media/src/main.py (144-149)
Instead of manually constructing the config dictionary, use model_dump(exclude_none=True) to automatically include all relevant fields while filtering out None values and redundant fields like prompt and model.
config=input.model_dump(exclude_none=True, exclude={'prompt', 'model'}),py/samples/google-genai-media/src/main.py (47-80)
To reduce duplication and improve maintainability, VideoInput should inherit from VideoPresetInput. Additionally, the default value for resolution should be None to avoid sending it to models that might not support it (as it is a newer parameter).
class VideoPresetInput(BaseModel):
"""Input for fixed-model Veo flows in Dev UI."""
prompt: str = Field(
default='A paper airplane gliding through a bright classroom, cinematic slow motion',
description='Video prompt',
)
aspect_ratio: str = Field(default='16:9', description='Video aspect ratio')
duration_seconds: int = Field(default=5, description='Video duration in seconds')
resolution: str | None = Field(default=None, description='Output resolution (for supported models)')
seed: int | None = Field(default=None, description='Optional RNG seed')
class VideoInput(VideoPresetInput):
"""Input for Veo."""
model: Literal[
'googleai/veo-3.1-generate-preview',
'googleai/veo-3.1-fast-generate-preview',
'googleai/veo-3.0-generate-001',
'googleai/veo-3.0-fast-generate-001',
'googleai/veo-3.1-generate-001',
'googleai/veo-3.1-fast-generate-001',
'googleai/veo-2.0-generate-001',
] = Field(default='googleai/veo-3.1-generate-preview', description='Veo model for generation')py/samples/google-genai-media/src/main.py (174-181)
Since VideoInput now inherits from VideoPresetInput, you can pass the input object directly to the helper function instead of manually re-mapping every field.
return await _generate_video_for_model(input, input.model)
Summary
veo-3.1-generate-previewveo-3.1-fast-generate-previewveo-3.0-generate-001veo-3.0-fast-generate-001VeoConfigSchemawith newer Veo parameters used by these models (resolution,seed) while preserving existing aliases and passthrough behavior.google-genai-mediasample with dedicated Dev UI flows per Veo model:generate_video_veo31generate_video_veo31_fastgenerate_video_veo30generate_video_veo30_fastgenerate_videoflow for model-selectable testing.Examples
Checklist (if applicable):