oobabooga/textgen · error · ServiceUnavailableError
No image model loaded. Load a model via the UI first.
Error message
No image model loaded. Load a model via the UI first.
What it means
The image generation endpoint (/v1/images/generations style generations() in modules/api/images.py) requires an image/diffusion model to already be loaded into shared.image_model. The API only loads LLMs; diffusion models must be selected and loaded through the UI's image generation tab first. Absence raises ServiceUnavailableError (503).
Source
Thrown at modules/api/images.py:24
import io
import json
import time
from PIL.PngImagePlugin import PngInfo
from .errors import ServiceUnavailableError
from modules import shared
def generations(request):
"""
Generate images using the loaded diffusion model.
Returns dict with 'created' timestamp and 'data' list of images.
"""
from modules.ui_image_generation import build_generation_metadata, generate
if shared.image_model is None:
raise ServiceUnavailableError("No image model loaded. Load a model via the UI first.")
width, height = request.get_width_height()
# Build state dict: GenerationOptions fields + image-specific keys
state = request.model_dump()
state.update({
'image_model_menu': shared.image_model_name,
'image_prompt': request.prompt,
'image_neg_prompt': request.negative_prompt,
'image_width': width,
'image_height': height,
'image_steps': request.steps,
'image_seed': request.image_seed,
'image_batch_size': request.batch_size,
'image_batch_count': request.batch_count,
'image_cfg_scale': request.cfg_scale,
'image_llm_variations': False,
})View on GitHub (pinned to ed888c71f2)
Solutions
- Open the UI image generation tab, select a diffusion model, and wait for it to load before calling the API.
- For headless use, load the model once via the UI (or programmatic session) and keep the process alive.
- Verify readiness by checking the loaded image model via the models/status endpoints before calling generations.
- Treat 503 from this endpoint as 'warm-up required', not as a retryable transient.
Defensive patterns
Strategy: validation
Validate before calling
import requests
def image_model_loaded(base_url: str) -> bool:
# probe: a 503 with 'No image model loaded' means warm-up needed
r = requests.post(f'{base_url}/v1/images/generations', json={'prompt': 'probe', 'steps': 1}, timeout=30)
return r.status_code == 200 or 'No image model loaded' not in r.text Try / catch
try:
img = client.images.generate(model='x', prompt='a cat')
except openai.APIStatusError as e:
if e.status_code == 503 and 'No image model loaded' in str(e):
raise RuntimeError('Load a diffusion model in the UI image-generation tab before calling this API')
raise Prevention
- Load the diffusion model via the UI before starting API traffic.
- Don't auto-retry this 503; it is a state error, not transient.
- Add a readiness gate in your pipeline that probes the endpoint once before batch jobs.
When it happens
Trigger: POST /v1/images/generations (or equivalent) against a headless server started with --api where no diffusion model was loaded via the UI image-generation tab; after a model load failure or UI session reset; before visiting the image tab at all.
Common situations: Headless/API-only deployments assuming image models autoload; calling image generation right after server start; the diffusion model load previously failed leaving shared.image_model None.
Related errors
- Error: Failed to load embedding model: {model}
- Image generation failed or produced no images.
- functions is not supported.
- function_call is not supported.
- messages is required
AI-assisted analysis of oobabooga/textgen@ed888c71f2 (2026-08-15).
Data as JSON: /api/errors/9076d38b7a1a6e2a.
Report an issue: GitHub.