> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/open-webui/open-webui/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Image

Generate images from text prompts using various AI image generation engines including OpenAI DALL-E, Gemini Imagen, ComfyUI, and Automatic1111.

## Request

### Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Body

<ParamField body="prompt" type="string" required>
  Text description of the image to generate
</ParamField>

<ParamField body="model" type="string">
  Model to use for generation. Defaults to configured model.

  **OpenAI models:**

  * `dall-e-2`
  * `dall-e-3`
  * `gpt-image-1`
  * `gpt-image-1.5`

  **Gemini models:**

  * `imagen-3.0-generate-002`
</ParamField>

<ParamField body="size" type="string">
  Image dimensions in format `WIDTHxHEIGHT` (e.g., `512x512`, `1024x1024`)

  Can also be `auto` for models that support dynamic sizing.
</ParamField>

<ParamField body="n" type="number" default="1">
  Number of images to generate
</ParamField>

<ParamField body="steps" type="number">
  Number of inference steps (for Stable Diffusion-based engines)
</ParamField>

<ParamField body="negative_prompt" type="string">
  Negative prompt describing what to avoid in the image (for Stable Diffusion-based engines)
</ParamField>

## Response

Returns an array of generated image objects.

<ResponseField name="url" type="string">
  URL path to access the generated image file
</ResponseField>

## Example

```bash theme={null}
curl -X POST https://your-domain.com/api/images/generations \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A serene mountain landscape at sunset with a lake",
    "model": "dall-e-3",
    "size": "1024x1024",
    "n": 1
  }'
```

```json Response theme={null}
[
  {
    "url": "/api/v1/files/550e8400-e29b-41d4-a716-446655440000/content"
  }
]
```

## Supported Engines

Configure the image generation engine in Admin Settings > Images:

### OpenAI DALL-E

* Cloud-based image generation
* Models: DALL-E 2, DALL-E 3, GPT-IMAGE series
* Requires OpenAI API key
* Supports various sizes depending on model

### Gemini Imagen

* Google's Imagen 3.0 model
* Two endpoint methods: `predict` or `generateContent`
* Requires Google API key

### ComfyUI

* Local/self-hosted image generation
* Highly customizable workflows
* Supports custom models and nodes
* Configure workflow JSON and node mappings

### Automatic1111 (Stable Diffusion WebUI)

* Popular Stable Diffusion interface
* Full control over generation parameters
* Supports negative prompts and custom steps
* Optional API authentication

## Advanced Parameters

For Stable Diffusion-based engines (ComfyUI, Automatic1111):

```json theme={null}
{
  "prompt": "A futuristic city at night",
  "negative_prompt": "blurry, low quality, distorted",
  "size": "768x768",
  "steps": 50,
  "n": 2
}
```

## Image Storage

Generated images are:

1. Automatically uploaded to the files system
2. Associated with the user who generated them
3. Accessible via the standard file content endpoint
4. Linked to chat messages if `chat_id` and `message_id` are provided in metadata

## Permissions

Requires the `features.image_generation` permission. Admin users have access by default.

## Error Responses

<ResponseField name="400">
  Invalid parameters or generation failed
</ResponseField>

<ResponseField name="403">
  Image generation is disabled or user lacks permission
</ResponseField>

## Related Endpoints

* `POST /api/images/edit` - Edit existing images with prompts
* `GET /api/images/models` - List available models for current engine
* `GET /api/images/config` - Get image generation configuration (admin only)
