image
Google AI image generation service implementation.
This module provides integration with Google’s Gemini image models for generating images from text prompts using the Gemini API.
- class pipecat.services.google.image.GoogleImageGenSettings(model: str | None | NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, number_of_images: int | NotGiven = <factory>, aspect_ratio: str | None | NotGiven = <factory>, image_size: Literal['1K', '2K', '4K'] | str | None | ~pipecat.utils.types.NotGiven=<factory>, negative_prompt: str | None | NotGiven = <factory>)[source]
Bases:
ImageGenSettingsSettings for the Google image generation service.
- Parameters:
model – Gemini image model identifier.
number_of_images – Number of images to generate per prompt.
aspect_ratio – Aspect ratio of generated images, such as
"1:1"or"16:9".Noneleaves the model’s own default in place.image_size – Resolution of generated images, one of
"1K","2K"or"4K".Noneleaves the model’s own default in place. Supported sizes vary by model.negative_prompt –
Text describing what not to include in generated images.
Deprecated since version 1.13.0: No replacement. Gemini image models do not accept a negative prompt, so the value is ignored. Will be removed in 2.0.0.
- class pipecat.services.google.image.GoogleImageGenService(*, api_key: str, params: InputParams | None = None, http_options: Any | None = None, settings: GoogleImageGenSettings | None = None, **kwargs)[source]
Bases:
ImageGenServiceGoogle AI image generation service using Gemini image models.
Provides text-to-image generation using Google’s Gemini image models through the Gemini API. Each image is a separate request, so
number_of_imagesimages are generated one after another.- Settings
alias of
GoogleImageGenSettings
- class InputParams(*, number_of_images: Annotated[int, Ge(ge=1), Le(le=8)] = 1, model: str = 'gemini-3.1-flash-image', negative_prompt: str | None = None)[source]
Bases:
BaseModelConfiguration parameters for Google image generation.
Deprecated since version 0.0.105: Use
settings=GoogleImageGenService.Settings(...)instead. Will be removed in 2.0.0.- Parameters:
number_of_images – Number of images to generate (1-8). Defaults to 1.
model – Gemini image model to use. Defaults to “gemini-3.1-flash-image”.
negative_prompt – Ignored; Gemini image models do not accept a negative prompt.
- __init__(*, api_key: str, params: InputParams | None = None, http_options: Any | None = None, settings: GoogleImageGenSettings | None = None, **kwargs)[source]
Initialize the GoogleImageGenService with API key and parameters.
- Parameters:
api_key – Google AI API key for authentication.
params –
Configuration parameters for image generation.
Deprecated since version 0.0.105: Use
settings=GoogleImageGenService.Settings(...)instead. Will be removed in 2.0.0.http_options – HTTP options for the client.
settings – Runtime-updatable settings. When provided alongside deprecated parameters,
settingsvalues take precedence.**kwargs – Additional arguments passed to the parent ImageGenService.
- can_generate_metrics() bool[source]
Check if this service can generate processing metrics.
- Returns:
True, as Google image generation service supports metrics.
- async run_image_gen(prompt: str) AsyncGenerator[Frame, None][source]
Generate images from a text prompt using a Gemini image model.
- Parameters:
prompt – The text description to generate images from.
- Yields:
Frame –
- Generated URLImageRawFrame objects containing the generated
images, or ErrorFrame objects if generation fails.