---
title: "Vertex AI Image Generation"
url: "/docs/providers/vertex_image"
canonical_url: "https://docs.litellm.ai/docs/providers/vertex_image"
type: "docs"
last_updated: "2026-10-06"
summary: "Vertex AI supports two types of image generation:"
related:
  - "/docs/providers/vertex_embedding"
  - "/docs/providers/vertex_speech"
---
# Vertex AI Image Generation

> Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt


Vertex AI supports two types of image generation:

1. **Gemini Image Generation Models** (Nano Banana 🍌) - Conversational image generation using `generateContent` API
2. **Imagen Models** - Traditional image generation using `predict` API

| Property | Details |
|----------|---------|
| Description | Vertex AI Image Generation supports both Gemini image generation models |
| Provider Route on LiteLLM | `vertex_ai/` |
| Provider Doc | [Google Cloud Vertex AI Image Generation ↗](https://cloud.google.com/vertex-ai/docs/generative-ai/image/generate-images) |
| Gemini Image Generation Docs | [Gemini Image Generation ↗](https://ai.google.dev/gemini-api/docs/image-generation) |

## Quick Start

### Gemini Image Generation Models

Gemini image generation models support conversational image creation with features like:
- Text-to-Image generation
- Image editing (text + image → image)
- Multi-turn image refinement
- High-fidelity text rendering
- Up to 4K resolution (Gemini 3 Pro)

```python showLineNumbers title="Gemini 2.5 Flash Image"
import litellm

# Generate a single image
response = await litellm.aimage_generation(
    prompt="A nano banana dish in a fancy restaurant with a Gemini theme",
    model="vertex_ai/gemini-2.5-flash-image",
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
    n=1,
    size="1024x1024",
)

print(response.data[0].b64_json)  # Gemini returns base64 images
```

```python showLineNumbers title="Gemini 3 Pro Image Preview (4K output)"
import litellm

# Generate high-resolution image
response = await litellm.aimage_generation(
    prompt="Da Vinci style anatomical sketch of a dissected Monarch butterfly",
    model="vertex_ai/gemini-3-pro-image-preview",
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
    n=1,
    size="1024x1024",
    # Optional: specify image size for Gemini 3 Pro
    # imageSize="4K",  # Options: "1K", "2K", "4K"
)

print(response.data[0].b64_json)
```

### Google Search Grounding

Gemini image models (e.g. `gemini-3.1-flash-image-preview`, `gemini-3-pro-image-preview`) support Google Search on `/v1/images/generations`. LiteLLM maps `web_search_options` or OpenAI-style `web_search` tools to Gemini's `googleSearch` tool on the underlying `generateContent` request.

```python showLineNumbers title="Image generation with Google Search"
import litellm

response = await litellm.aimage_generation(
    prompt="Generate an image of the latest iPhone design",
    model="vertex_ai/gemini-3.1-flash-image-preview",
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
    web_search_options={},
)

print(response.data[0].b64_json)
```

```python showLineNumbers title="Using OpenAI-style web_search tool"
import litellm

response = await litellm.aimage_generation(
    prompt="Generate an image of the latest iPhone design",
    model="vertex_ai/gemini-3.1-flash-image-preview",
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
    tools=[{"type": "web_search"}],
)
```

Via LiteLLM Proxy (`/v1/images/generations`):

```bash showLineNumbers title="Proxy request with web_search_options"
curl -X POST 'http://localhost:4000/v1/images/generations' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-d '{
    "model": "gemini-3.1-flash-image-preview",
    "prompt": "Generate an image of the latest iPhone design",
    "web_search_options": {}
}'
```

### Passing imageConfig (Gemini models)

Gemini image generation models support the full [`ImageConfig`](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1#imageconfig) object. Pass it as `imageConfig` on any `/v1/images/generations` request and LiteLLM will forward all fields verbatim to `generationConfig.imageConfig`.

| Field | Type | Description |
|---|---|---|
| `aspectRatio` | string | `"1:1"`, `"16:9"`, `"9:16"`, `"4:3"`, `"3:4"`, `"4:5"`, `"5:4"`, `"2:3"`, `"3:2"`, `"21:9"` |
| `imageSize` | string | `"1K"`, `"2K"`, `"4K"` (supported on Gemini 3 Pro and newer) |
| `personGeneration` | string | `"DONT_ALLOW"`, `"ALLOW_ADULT"`, `"ALLOW_ALL"` |
| `imageOutputOptions` | object | `{"mimeType": "image/jpeg"\|"image/png"\|"image/webp", "compressionQuality": 0–100}` |

```python showLineNumbers title="Passing imageConfig via Python SDK"
import litellm

response = await litellm.aimage_generation(
    model="vertex_ai/gemini-3.1-flash-image",
    prompt="A nano banana on a desk",
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
    imageConfig={
        "aspectRatio": "16:9",
        "imageSize": "2K",
        "personGeneration": "DONT_ALLOW",
        "imageOutputOptions": {
            "mimeType": "image/jpeg",
            "compressionQuality": 85,
        },
    },
)
```

```bash showLineNumbers title="Passing imageConfig via Proxy"
curl -X POST 'http://localhost:4000/v1/images/generations' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-d '{
    "model": "gemini-3.1-flash-image",
    "prompt": "A nano banana on a desk",
    "imageConfig": {
        "aspectRatio": "16:9",
        "imageSize": "2K",
        "personGeneration": "DONT_ALLOW",
        "imageOutputOptions": {
            "mimeType": "image/jpeg",
            "compressionQuality": 85
        }
    }
}'
```

You can also use flat params as shorthand for `aspectRatio` and `imageSize`:

```python showLineNumbers title="Flat param shorthand"
response = await litellm.aimage_generation(
    model="vertex_ai/gemini-3.1-flash-image",
    prompt="A nano banana on a desk",
    aspect_ratio="16:9",   # or aspectRatio="16:9"
    image_size="2K",       # or imageSize="2K"
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
)
```

Flat params (`aspect_ratio`, `image_size`, `aspectRatio`, `imageSize`) override the same key inside `imageConfig` when both are present.

### Imagen Models

```python showLineNumbers title="Imagen Image Generation"
import litellm

# Generate a single image
response = await litellm.aimage_generation(
    prompt="An olympic size swimming pool with crystal clear water and modern architecture",
    model="vertex_ai/imagen-4.0-generate-001",
    vertex_ai_project="your-project-id",
    vertex_ai_location="us-central1",
    n=1,
    size="1024x1024",
)

print(response.data[0].b64_json)  # Imagen also returns base64 images
```

### LiteLLM Proxy

#### 1. Configure your config.yaml

```yaml showLineNumbers title="Vertex AI Image Generation Configuration"
model_list:
  - model_name: vertex-imagen
    litellm_params:
      model: vertex_ai/imagen-4.0-generate-001
      vertex_ai_project: "your-project-id"
      vertex_ai_location: "us-central1"
      vertex_ai_credentials: "path/to/service-account.json"  # Optional if using environment auth
```

#### 2. Start LiteLLM Proxy Server

```bash title="Start LiteLLM Proxy Server"
litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000
```

#### 3. Make requests with OpenAI Python SDK

```python showLineNumbers title="Basic Image Generation via Proxy"
from openai import OpenAI

# Initialize client with your proxy URL
client = OpenAI(
    base_url="http://localhost:4000",  # Your proxy URL
    api_key="your-proxy-api-key"      # Your proxy API key
)

# Generate image
response = client.images.generate(
    model="vertex-imagen",
    prompt="An olympic size swimming pool with crystal clear water and modern architecture",
)

print(response.data[0].url)
```

## Supported Models

### Gemini Image Generation Models

- `vertex_ai/gemini-2.5-flash-image` - Fast, efficient image generation (1024px resolution)
- `vertex_ai/gemini-3.1-flash-image-preview` - Fast image generation with Google Search grounding
- `vertex_ai/gemini-3-pro-image-preview` - Advanced model with 4K output, Google Search grounding, and thinking mode
- `vertex_ai/gemini-2.0-flash-preview-image` - Preview model
- `vertex_ai/gemini-2.5-flash-image-preview` - Preview model

### Imagen Models

- `vertex_ai/imagegeneration@006` - Legacy Imagen model
- `vertex_ai/imagen-4.0-generate-001` - Latest Imagen model
- `vertex_ai/imagen-3.0-generate-001` - Imagen 3.0 model

:::tip

**We support ALL Vertex AI Image Generation models, just set `model=vertex_ai/<any-model-on-vertex_ai>` as a prefix when sending litellm requests**

:::

For the complete and up-to-date list of supported models, visit: [https://models.litellm.ai/](https://models.litellm.ai/)

## Related pages

- [Vertex AI Embedding](https://docs.litellm.ai/docs/providers/vertex_embedding.md)
- [Vertex AI Text to Speech](https://docs.litellm.ai/docs/providers/vertex_speech.md)
