Skip to main content

VertexAIImageGenerator

Generate images using Google Vertex AI generative model.

Basic Information

  • Type: haystack_integrations.components.generators.google_vertex.image_generator.VertexAIImageGenerator
  • Components it can connect with:
    • PromptBuilder: Receives a text prompt as input.
    • Any component that accepts a list of ByteStream objects as input.

Inputs

ParameterTypeDefaultDescription
promptstrThe prompt to generate images from.
negative_promptOptional[str]NoneA description of what you want to omit in the generated images.

Outputs

ParameterTypeDefaultDescription
imagesList[ByteStream]A list of ByteStream objects, each containing an image.

Overview

VertexAIImageGenerator generates images using Google Vertex AI generative model. It takes a text prompt and optionally a negative prompt to generate images.

Authorization

This component authenticates using Google Cloud Application Default Credentials (ADCs). For more information, see the official Google documentation.

Create secrets for GCP_PROJECT_ID and optionally GCP_DEFAULT_REGION. For detailed instructions on creating secrets, see Create Secrets.

Usage Example

This pipeline uses VertexAIImageGenerator to generate images from text prompts:

components:
VertexAIImageGenerator:
type: haystack_integrations.components.generators.google_vertex.image_generator.VertexAIImageGenerator
init_parameters:
project_id:
model: imagegeneration
location:
PromptBuilder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: "Generate an image described in the query.\n\nQuery: {{ query }}"
required_variables: "\\n"
variables:

max_runs_per_component: 100

metadata: {}

connections:
- sender: PromptBuilder.prompt
receiver: VertexAIImageGenerator.prompt

inputs:
query:
- PromptBuilder.query

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
project_idOptional[str]NoneID of the GCP project to use. By default, it is set during Google Cloud authentication.
modelstrimagegenerationName of the model to use.
locationOptional[str]NoneThe default location to use when making API calls. If not set, uses us-central-1.
kwargsAnyAdditional keyword arguments to pass to the model. See the ImageGenerationModel.generate_images() documentation.

Run Method Parameters

These are the parameters you can configure for the run() method. You can pass these parameters at query time through the API, in Playground, or when running a job.

ParameterTypeDefaultDescription
promptstrThe prompt to generate images from.
negative_promptOptional[str]NoneA description of what you want to omit in the generated images.