Skip to main content

Method Signature

Description

Generates images based on a text description using Imagen models. Supports various image generation parameters including aspect ratio, safety filters, and output format control.

Parameters

str
required
The Imagen model to use for generation.Examples:
  • 'imagen-3.0-generate-002'
  • 'imagen-3.0-fast-generate-001'
  • 'imagen-3.0-generate-001'
str
required
A text description of the images to generate.Example: 'A serene mountain landscape at sunset with a lake in the foreground'
GenerateImagesConfig
Configuration for image generation.

Response

list[GeneratedImage]
List of generated images.
SafetyAttributes
Safety attributes for the prompt itself

Code Examples

Basic Image Generation

Multiple Images with Custom Settings

With Negative Prompt and Safety Settings

Save to Cloud Storage

High-Quality Output Settings

Async Usage

Notes

  • Generation typically takes 5-30 seconds depending on the model and settings
  • Some configuration options are only available on Vertex AI
  • Images may be filtered by safety systems if they violate content policies
  • Use include_rai_reason=True to understand why images were filtered
  • The enhance_prompt feature can significantly improve results but may alter your intent
  • Higher guidance_scale values make the model follow the prompt more closely but may reduce creativity
See the Imagen guide for more information on editing and upscaling images with edit_image and upscale_image methods.