-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Feature requestNew feature requestNew feature request
Description
Description
Recently Gemini launched support for aspect ratio control during image generation.
Supported ratios include:
- Landscape: 21:9, 16:9, 4:3, 3:2
- Square: 1:1
- Portrait: 9:16, 3:4, 2:3
- Flexible: 5:4, 4:5
# code from google's documentation
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents=[prompt, image],
config=types.GenerateContentConfig(
response_modalities=["IMAGE"],
image_config=types.ImageConfig(
aspect_ratio="16:9",
)
)
)Perhaps the BinaryImage object could be updated to support an aspect_ratio (Optional[str]) arg
from pydantic_ai import BinaryImage
# just an example
nano_banana_agent = Agent(
output_type=BinaryImage(aspect_ratio="16:9",
**kwargs,
)
response = await nano_banana_agent.run(user_prompt="Generate a cartoony image of halloween")
# return base64 image in the desired aspect ratio
return response.output.data_uriReferences
Blog from google dev: https://developers.googleblog.com/en/gemini-2-5-flash-image-now-ready-for-production-with-new-aspect-ratios/
nicolas-chaulet and DavidVaness
Metadata
Metadata
Assignees
Labels
Feature requestNew feature requestNew feature request