image
Google AI image generation service implementation.
This module provides integration with Google’s Imagen model for generating images from text prompts using the Google AI API.
- class pipecat.services.google.image.GoogleImageGenSettings(model: str | None | _NotGiven = <factory>, extra: dict[str, ~typing.Any]=<factory>, number_of_images: int | _NotGiven = <factory>, negative_prompt: str | None | _NotGiven = <factory>)[source]
Bases:
ImageGenSettingsSettings for the Google image generation service.
- Parameters:
model – Google Imagen model identifier.
number_of_images – Number of images to generate per request.
negative_prompt – Text describing what not to include in generated images.
- number_of_images: int | _NotGiven
- negative_prompt: str | None | _NotGiven
- 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 Imagen models.
Provides text-to-image generation capabilities using Google’s Imagen models through the Google AI API. Supports multiple image generation and negative prompting for enhanced control over generated content.
- Settings
alias of
GoogleImageGenSettings
- class InputParams(*, number_of_images: Annotated[int, Ge(ge=1), Le(le=8)] = 1, model: str = 'imagen-4.0-generate-001', negative_prompt: str | None = None)[source]
Bases:
BaseModelConfiguration parameters for Google image generation.
Deprecated since version 0.0.105: Use
settings=GoogleImageGenService.Settings(...)instead.- Parameters:
number_of_images – Number of images to generate (1-8). Defaults to 1.
model – Google Imagen model to use. Defaults to “imagen-4.0-generate-001”.
negative_prompt – Optional negative prompt to guide what not to include.
- number_of_images: int
- model: str
- negative_prompt: str | None
- __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.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 Google’s Imagen 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.
- Raises:
Exception – If there are issues with the Google AI API or image processing.