---
related_nodes: ["upload_media", "read_media", "process_image"]
---

# Generate Image

Generates an image from a text prompt using a configured AI image generation provider. Supports DALL-E 3, Google Gemini, Stable Diffusion, Flux, and more.

## What It Does

The Generate Image node takes a text prompt, optional source images, and optional parameters (negative prompt, aspect ratio, seed), then sends them to your configured image generation model through a workspace connection. The model generates or edits an image, which is returned as a binary object on the `output` socket.

Key capabilities:
- **Text-to-image**: Generate images from natural language descriptions
- **Image-conditioned generation**: Feed one source image or a list of source images to models that support edits/composition
- **Provider diversity**: OpenAI (DALL-E 3), xAI, Google Gemini, Stability AI, Replicate, Fal.ai
- **Configuration controls**: Aspect ratio, negative prompting, seed for reproducibility
- **Binary output**: Returns raw image bytes with content type, filename, and dimensions when available

## When to Use

- Generating illustrations for documents or reports
- Creating visual assets for social media or presentations
- Producing design mockups from text descriptions
- Combining concept art or reference images into a generated result
- Building automated image generation pipelines
- Generating test images for e2e verification (test_image provider)

## How It Works

1. **Model resolution**: The configured connection and model are validated against the ImageGenerator model kind
2. **Provider dispatch**: The provider ID is matched to the correct provider implementation
3. **Image input resolution**: Optional `images` input is resolved from binary, base64 JSON, URL, or stored media reference
4. **API request**: The prompt, optional images, and optional parameters are sent to the provider endpoint
5. **Response handling**: The returned image bytes, content type, and dimensions (when known) are packaged into the binary output object
6. **Downstream flow**: Use `upload_media` to persist the image to workspace storage

## Inputs

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `input` | any | No | Optional input data for prompt interpolation |
| `images` | media input or media input[] | No | Source image or images for model-supported edits/composition |

`images` accepts runtime binary, `{ binary }`, `{ base64, mime_type, filename? }`, `{ url }`, `http`/`https` URL, an object descriptor, `{ object_id }`, or a list of those values. Source inputs must resolve to `image/*` content.

## Configuration

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | model | Yes | Image generation connection and model |
| `prompt` | text | Yes | Text prompt describing the image to generate. Supports template interpolation |
| `negative_prompt` | text | No | Text prompt describing what to avoid in the image |
| `aspect_ratio` | string | No | Desired aspect ratio (provider-dependent, e.g., "16:9", "1:1") |
| `seed` | number | No | Random seed for reproducible generation |
| `output_format` | string | No | Desired output format (provider-dependent, e.g., "png", "jpeg") |

## Output

| Name | Type | Description |
|------|------|-------------|
| `output` | object | Binary image output with `binary`, `filename`, `content_type`, `width`, `height` fields |

The output object includes:
- `binary`: Raw image bytes
- `filename`: Generated filename (e.g., `test-image-black.png`)
- `content_type`: MIME type (e.g., `image/png`)
- `width`: Image width in pixels (when available from provider)
- `height`: Image height in pixels (when available from provider)

## Supported Providers

| Provider | Models | Notes |
|----------|--------|-------|
| OpenAI | GPT Image | Bearer auth, base64 response. GPT Image models support `images` input through image edits |
| xAI | grok-image-2 | OpenAI-compatible API |
| Google Gemini | Gemini image models | API key auth. Gemini image models support inline `images` input |
| Stability AI | stable-image-core, stable-image-ultra | Multipart form, raw image response |
| Replicate | flux-dev, flux-schnell | Async polling with exponential backoff |
| Fal.ai | flux-dev, flux-schnell | Key auth, async polling |
| Test Image | black-png-v1 | Deterministic 1x1 black PNG for testing |

## Caveats

- Width/height are `None` for some providers that do not return dimensions
- Output is a raw binary object; use `upload_media` downstream to persist to workspace storage
- Async providers (Replicate, Fal.ai) use exponential backoff: 1s → 2s → 4s, capped at 10s, max 120s total
- Provider-specific parameter support varies
- If `images` is connected to a model that does not support input images, the node fails instead of silently ignoring them
