chore: import upstream snapshot with attribution
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:22:28 +08:00
commit c56bef871b
9296 changed files with 1854228 additions and 0 deletions
@@ -0,0 +1,80 @@
---
title: "VertexAIImageGenerator"
id: vertexaiimagegenerator
slug: "/vertexaiimagegenerator"
description: "This component enables image generation using Google Vertex AI generative model."
---
# VertexAIImageGenerator
This component enables image generation using Google Vertex AI generative model.
<div className="key-value-table">
| | |
| --- | --- |
| **Mandatory run variables** | `prompt`: A string containing the prompt for the model |
| **Output variables** | `images`: A list of [`ByteStream`](../../concepts/data-classes.mdx#bytestream) containing images generated by the model |
| **API reference** | [Google Vertex](/reference/integrations-google-vertex) |
| **GitHub link** | https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/google_vertex |
</div>
`VertexAIImageGenerator` supports the `imagegeneration` model.
### Parameters Overview
`VertexAIImageGenerator` uses Google Cloud Application Default Credentials (ADCs) for authentication. For more information on how to set up ADCs, see the [official documentation](https://cloud.google.com/docs/authentication/provide-credentials-adc).
Keep in mind that its essential to use an account that has access to a project authorized to use Google Vertex AI endpoints.
You can find your project ID in the [GCP resource manager](https://console.cloud.google.com/cloud-resource-manager) or locally by running `gcloud projects list` in your terminal. For more info on the gcloud CLI, see its [official documentation](https://cloud.google.com/cli).
## Usage
You need to install `google-vertex-haystack` package to use the `VertexAIImageGenerator`:
```python
pip install google-vertex-haystack
```
### On its own
Basic usage:
```python
from pathlib import Path
from haystack_integrations.components.generators.google_vertex import (
VertexAIImageGenerator,
)
generator = VertexAIImageGenerator()
result = generator.run(prompt="Generate an image of a cute cat")
result["images"][0].to_file(Path("my_image.png"))
```
You can also set other parameters like the number of images generated and the guidance scale to change the strength of the prompt.
Lets also use a negative prompt to omit something from the image:
```python
from pathlib import Path
from haystack_integrations.components.generators.google_vertex import (
VertexAIImageGenerator,
)
generator = VertexAIImageGenerator(
number_of_images=3,
guidance_scale=12,
)
result = generator.run(
prompt="Generate an image of a cute cat",
negative_prompt="window, chair",
)
for i, image in enumerate(result["images"]):
images.to_file(Path(f"image_{i}.png"))
```