open-webui/open-webui · error · HTTPException
[ERROR: Failed to connect to the image generation engine]
Error message
[ERROR: Failed to connect to the image generation engine]
What it means
Raised while resolving the default model when IMAGE_GENERATION_ENGINE is 'automatic1111' (or empty): the code GETs {AUTOMATIC1111_BASE_URL}/sdapi/v1/options and any exception — connection refused, timeout, bad JSON, missing 'sd_model_checkpoint' key — becomes HTTP 400 'Failed to connect to the image generation engine' (images.py:214-222).
Source
Thrown at backend/open_webui/routers/images.py:222
if image_config.IMAGE_GENERATION_ENGINE == 'openai':
return image_config.IMAGE_GENERATION_MODEL if image_config.IMAGE_GENERATION_MODEL else 'dall-e-2'
elif image_config.IMAGE_GENERATION_ENGINE == 'gemini':
return image_config.IMAGE_GENERATION_MODEL if image_config.IMAGE_GENERATION_MODEL else 'imagen-3.0-generate-002'
elif image_config.IMAGE_GENERATION_ENGINE == 'comfyui':
return image_config.IMAGE_GENERATION_MODEL if image_config.IMAGE_GENERATION_MODEL else ''
elif image_config.IMAGE_GENERATION_ENGINE == 'automatic1111' or image_config.IMAGE_GENERATION_ENGINE == '':
try:
session = await get_session()
async with session.get(
url=f'{image_config.AUTOMATIC1111_BASE_URL}/sdapi/v1/options',
headers={'authorization': get_automatic1111_api_auth(image_config)},
ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as r:
options = await r.json()
return options['sd_model_checkpoint']
except Exception as e:
log.exception(f'Failed to get default model from automatic1111: {e}')
raise HTTPException(
status_code=400,
detail=ERROR_MESSAGES.DEFAULT(e, 'Failed to connect to the image generation engine'),
)
class ImagesConfig(BaseModel):
ENABLE_IMAGE_GENERATION: bool
ENABLE_IMAGE_PROMPT_GENERATION: bool
IMAGE_GENERATION_ENGINE: str
IMAGE_GENERATION_MODEL: str
IMAGE_SIZE: str | None
IMAGE_STEPS: int | None
IMAGES_OPENAI_API_BASE_URL: str
IMAGES_OPENAI_API_KEY: str
IMAGES_OPENAI_API_VERSION: str
IMAGES_OPENAI_API_PARAMS: dict | str | NoneView on GitHub (pinned to 01f4282f1f)
Solutions
- curl {AUTOMATIC1111_BASE_URL}/sdapi/v1/options from the Open WebUI host — it must return JSON containing sd_model_checkpoint
- Restart Automatic1111 with --api (and --listen if remote) and fix AUTOMATIC1111_BASE_URL in Admin Settings > Images
- For HTTPS with self-signed certs, configure the trusted CA via AIOHTTP_CLIENT_SESSION_SSL / persistent_config rather than disabling checks broadly
- If the key is missing, upgrade the A1111 API version or pin an engine/model explicitly so the checkpoint lookup is skipped
Example fix
# before: wrong base URL AUTOMATIC1111_BASE_URL=http://localhost:7860/ # A1111 actually listening on 0.0.0.0:7861 with --api # after AUTOMATIC1111_BASE_URL=http://a1111-host:7861/ # launch: python launch.py --api --listen --port 7861
Defensive patterns
Strategy: try-catch
Validate before calling
import httpx, os
async def a1111_alive(base_url: str) -> bool:
try:
r = await httpx.get(f'{base_url}/sdapi/v1/options', timeout=5)
return r.status_code == 200 and 'sd_model_checkpoint' in r.json()
except Exception:
return False Try / catch
try:
model = await client.get('/api/v1/images/config') # any path resolving the A1111 checkpoint
except httpx.HTTPStatusError as e:
if 'Failed to connect to the image generation engine' in e.response.text:
raise RuntimeError('Automatic1111 unreachable: check AUTOMATIC1111_BASE_URL and --api flag')
raise Prevention
- Start A1111 with --api and verify /sdapi/v1/options before saving image config
- Health-check the engine URL from the Open WebUI host/container, not your browser
- Keep AUTOMATIC1111_BASE_URL in sync when the engine moves (host, port, TLS)
When it happens
Trigger: Any admin config/image-model request that resolves the A1111 checkpoint while the Automatic1111 (stable-diffusion-webui) API is down, AUTOMATIC1111_BASE_URL is wrong (missing http://, wrong port, or pointing at the UI instead of the --api endpoint), TLS verification fails, or the response lacks sd_model_checkpoint because the API version is old.
Common situations: A1111 launched without the --api flag; base URL left at default after moving the service; self-signed HTTPS with AIOHTTP_CLIENT_SESSION_SSL rejecting it; A1111 updated and changed its options schema.
Related errors
- The URL you provided is invalid. Please double-check and try
- [ERROR: Failed to retrieve image generation models]
- Invalid format. Please use the correct format (auto is only
- Invalid format. Please use the correct format (e.g., 512x51
- Invalid format. Please use the correct format (e.g., 50).
AI-assisted analysis of open-webui/open-webui@01f4282f1f (2026-08-14).
Data as JSON: /api/errors/901d66c7b1d65f64.
Report an issue: GitHub.