Complete configuration reference for the Image Generation API.
LITELLM_BASE_URL
- LiteLLM proxy base URL
- Example:
http://litellm:4000orhttp://localhost:4000 - Required for LiteLLM provider
- Leave empty to disable LiteLLM
LITELLM_API_KEY
- API key for LiteLLM authentication
- Optional, depends on your LiteLLM configuration
- Leave empty if your LiteLLM instance doesn't require auth
OPENAI_API_KEY
- OpenAI API key for direct access
- Required for
provider="openai" - Format:
sk-... - Get from: https://platform.openai.com/api-keys
GEMINI_API_KEY
- Google Gemini API key for direct access
- Required for
provider="gemini" - Get from: https://aistudio.google.com/apikey
STORAGE_PATH
- Local directory for generated images
- Default:
./generated_images - Docker: Use volume mount (e.g.,
/app/generated_images)
IMAGE_BASE_URL
- Public base URL for serving images
- Default:
http://localhost:8000 - Example:
https://api.example.com - Used to construct full image URLs
SAVE_IMAGES_LOCALLY
- Save images to local disk
- Default:
true - Set to
falsewhen usingOPENWEBUI_MODE=trueorMARKDOWN_EMBED_IMAGES=true - When
false, images are temporarily written for base64 conversion then deleted
DEFAULT_MODEL
- Default model for generation/editing when not specified in request
- Example:
gpt-image-1,gpt-image-1.5 - Optional - if not set, first available model is used
OPENWEBUI_MODE
- Enable Open WebUI tool integration mode
- Default:
false - When
trueandOPENWEBUI_BASE_URL+OPENWEBUI_API_KEYare set:- Uploads images to Open WebUI's file storage via
/api/v1/files/ - Returns JSON with the OWUI file URL and markdown
- Images display natively in Open WebUI (with download/save)
- Falls back to base64 HTMLResponse if upload fails
- Uploads images to Open WebUI's file storage via
- When
truewithout OWUI upload configured:- Returns HTML with base64-encoded
<img>tag (legacy iframe mode)
- Returns HTML with base64-encoded
- When
false:- Normal API behavior based on
response_formatparameter
- Normal API behavior based on
OPENWEBUI_BASE_URL
- Open WebUI server URL for file upload integration
- Example:
http://open-webui:3000orhttp://localhost:3000 - Optional - leave empty to use legacy base64 HTMLResponse mode
- Used with
OPENWEBUI_MODE=trueto upload images directly to OWUI
OPENWEBUI_API_KEY
- API key for Open WebUI authentication
- Required when
OPENWEBUI_BASE_URLis set - Generate in Open WebUI: Settings > Account > API Keys
- Used for
POST /api/v1/files/uploads
MARKDOWN_EMBED_IMAGES
- Embed images as base64 data URI in markdown responses
- Default:
false - When
trueandresponse_format="markdown": Returns{"markdown": ""} - When
falseandresponse_format="markdown": Returns{"markdown": ""} - Note: Ignored when
OPENWEBUI_MODE=true
API_BEARER_TOKEN
- Bearer token for API authentication
- Optional - leave empty to disable auth
- When set, all requests must include
Authorization: Bearer <token>header - Generate secure token:
openssl rand -base64 32
MODEL_CACHE_TTL
- Model list cache duration in seconds
- Default:
3600(1 hour) - Increase for production to reduce LiteLLM API calls
- Decrease for development for faster model updates
HOST
- Host to bind server to
- Default:
0.0.0.0(all interfaces) - Use
127.0.0.1for localhost only
PORT
- Port to listen on
- Default:
8000 - Change if port conflicts exist
gpt-image-1.5 (latest)
- Aspect Ratios:
1:1,2:3,3:2 - Quality:
auto,high,medium,low - Max Images (n): 4
- Editing: Yes (mask-based)
gpt-image-1
- Aspect Ratios:
1:1,16:9,9:16 - Quality: Not supported
- Max Images (n): 4
- Editing: Yes (mask-based)
gpt-image-1-mini
- Aspect Ratios:
1:1,16:9,9:16 - Quality:
low,medium,high - Max Images (n): 4
- Editing: Yes (mask-based)
dall-e-3 (deprecated — shutting down May 12, 2026)
- Aspect Ratios:
1:1,16:9,9:16 - Quality:
standard,hd - Max Images (n): 1
- Editing: No
dall-e-2 (deprecated — shutting down May 12, 2026)
- Aspect Ratios:
1:1only - Quality: Not supported
- Max Images (n): 4
- Editing: Yes (mask-based)
gemini-2.5-flash-image (recommended)
- Aspect Ratios:
1:1,16:9,9:16,4:3,3:4,2:3,3:2 - Quality: Not supported
- Max Images (n): 4
- Editing: Yes (prompt-based)
gemini-3-pro-image-preview (preview)
- Aspect Ratios:
1:1,2:3,3:2,3:4,4:3,4:5,5:4,9:16,16:9,21:9 - Quality: Not supported
- Max Images (n): 4
- Editing: Yes (prompt-based)
gemini-2.0-flash-preview-image-generation (deprecated — shutting down March 31, 2026)
- Aspect Ratios:
1:1,16:9,9:16,4:3,3:4 - Quality: Not supported
- Max Images (n): 4
- Editing: Yes (prompt-based)
- Deploy LiteLLM proxy (Docker recommended):
services:
litellm:
image: ghcr.io/berriai/litellm:latest
ports:
- "4000:4000"
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- GEMINI_API_KEY=${GEMINI_API_KEY}- Configure this API:
LITELLM_BASE_URL=http://litellm:4000- Models are auto-discovered from LiteLLM
For fallback or without LiteLLM:
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...Set provider="openai" or provider="gemini" in requests.
{
"provider": "litellm" // or "openai", "gemini"
}litellm: Routes through LiteLLM proxy (recommended)openai: Direct OpenAI API callgemini: Direct Gemini API call
{
"model": "gpt-image-1" // or null for auto-select
}Leave null to use first available model for provider.
{
"aspect_ratio": "16:9"
}Options: 1:1, 16:9 (landscape), 9:16 (portrait), 4:3, 3:4, 2:3 (tall portrait), 3:2 (wide landscape)
Model compatibility:
- gpt-image-1.5:
1:1,2:3,3:2 - gpt-image-1 / gpt-image-1-mini:
1:1,16:9,9:16 - gemini-2.5-flash-image:
1:1,16:9,9:16,4:3,3:4,2:3,3:2 - gemini-3-pro-image-preview: All 10 ratios including
4:5,5:4,21:9 - dall-e-3 (deprecated):
1:1,16:9,9:16 - dall-e-2 (deprecated):
1:1only
{
"quality": "hd" // or "standard"
}Values depend on model:
- dall-e-3:
standard,hd - gpt-image-1.5:
auto,high,medium,low - gpt-image-1-mini:
low,medium,high - Other models: quality parameter ignored
{
"n": 4
}Constraints:
- dall-e-3: max 1
- imagen-4.0-ultra: max 1
- Others: max 4
The /edit endpoint supports two editing modes:
Used with gpt-image-1, gpt-image-1.5, gpt-image-1-mini, and dall-e-2. Requires:
image: Source image (upload or URL)mask: PNG with transparent areas marking regions to editprompt: Description of what to generate in masked area
The mask should have transparent (alpha=0) pixels where editing should occur.
Used with gemini-2.5-flash-image, gemini-3-pro-image-preview, and other Gemini models. Requires:
image: Source image (upload or URL)prompt: Natural language description of the edit
No mask needed - Gemini understands what to change from the prompt alone.
Images can be provided two ways:
- File upload:
image=@photo.png(multipart form) - URL reference:
image_url=http://localhost:8000/images/abc.png
URL reference works with previously generated images or external URLs.
Leave API_BEARER_TOKEN empty. All requests allowed.
- Generate secure token:
openssl rand -base64 32- Set in
.env:
API_BEARER_TOKEN=your-generated-token- Include in requests:
curl -H "Authorization: Bearer your-generated-token" \
http://localhost:8000/generateImages saved to STORAGE_PATH and served via /images/ endpoint.
Docker volume mount:
volumes:
- ./generated_images:/app/generated_imagesFor reverse proxy or custom domain:
IMAGE_BASE_URL=https://api.yourdomain.comImages will be served at: https://api.yourdomain.com/images/filename.png
Endpoint: GET /health
Response:
{
"status": "healthy",
"litellm": true,
"openai": true,
"gemini": false
}litellm: LiteLLM connectivityopenai: OpenAI API key configuredgemini: Gemini API key configured
Force reload models from LiteLLM:
curl -X POST http://localhost:8000/models/refresh \
-H "Content-Type: application/json" \
-d '{"force": true}'Use after LiteLLM configuration changes.
Models not loading
- Check
LITELLM_BASE_URLis accessible - Verify LiteLLM is running:
curl http://litellm:4000/health - Check logs for connection errors
Generation fails
- Verify API keys are correct
- Check model availability:
GET /models - Review provider status:
GET /health
Images not accessible
- Verify
STORAGE_PATHhas write permissions - Check
BASE_URLmatches your deployment - For Docker, ensure volume is mounted correctly
OPENWEBUI_MODE |
OWUI Upload | MARKDOWN_EMBED_IMAGES |
response_format |
Response |
|---|---|---|---|---|
true |
configured | (ignored) | (ignored) | {"image_url": "http://owui/api/v1/files/.../content", "markdown": ""} |
true |
not configured | (ignored) | (ignored) | HTML <img> with base64 data URI (iframe) |
false |
— | false |
url (default) |
{"image_url": "http://..."} |
false |
— | false |
base64 |
{"image_base64": "...", "mime_type": "..."} |
false |
— | false |
markdown |
{"markdown": ""} |
false |
— | true |
markdown |
{"markdown": ""} |