oobabooga/textgen · error · ServiceUnavailableError

Image generation failed or produced no images.

Error message

Image generation failed or produced no images.

What it means

After running the image generation pipeline (generator is exhausted with save_images=False), the endpoint expects at least one produced image. If the generator yields nothing or its final result is an empty list, ServiceUnavailableError (503) is raised, signaling the diffusion run failed silently (bad seed/step/cfg config, OOM, or pipeline error swallowed by the generator).

Source

Thrown at modules/api/images.py:50

        '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,
    })

    # Exhaust generator, keep final result
    images = []
    for images, _ in generate(state, save_images=False):
        pass

    if not images:
        raise ServiceUnavailableError("Image generation failed or produced no images.")

    # Build response with per-batch metadata (seed increments per batch)
    base_seed = state.get('image_seed_resolved', state['image_seed'])
    batch_size = int(state['image_batch_size'])

    resp = {'created': int(time.time()), 'data': []}
    for idx, img in enumerate(images):
        batch_seed = base_seed + idx // batch_size
        metadata = build_generation_metadata(state, batch_seed)
        metadata_json = json.dumps(metadata, ensure_ascii=False)
        png_info = PngInfo()
        png_info.add_text("image_gen_settings", metadata_json)
        b64 = _image_to_base64(img, png_info)

        image_obj = {'revised_prompt': request.prompt}

        if request.response_format == 'b64_json':
            image_obj['b64_json'] = b64

View on GitHub (pinned to ed888c71f2)

Solutions

  1. Retry the exact same generation through the UI image tab to see the real underlying error message.
  2. Reduce load: lower width/height, steps, batch_size and batch_count to baseline values.
  3. Re-download/re-verify the diffusion model checkpoint (hash/size) if generations consistently return empty.
  4. Check server logs around the request for CUDA OOM or pipeline exceptions.
Defensive patterns

Strategy: retry

Validate before calling

def sane_image_request(req: dict) -> bool:
    return (req.get('steps', 20) >= 1
            and 64 <= req.get('width', 512) <= 2048
            and 64 <= req.get('height', 512) <= 2048
            and 1 <= req.get('batch_size', 1) <= 4)

Try / catch

try:
    img = client.images.generate(model='x', prompt=p, size='512x512')
except openai.APIStatusError as e:
    if e.status_code == 503 and 'produced no images' in str(e):
        # one retry with reduced load, then surface the pipeline failure
        img = client.images.generate(model='x', prompt=p, size='256x256', steps=20)
    else:
        raise

Prevention

When it happens

Trigger: POST image generation where the underlying generate(state) generator completes without yielding images: e.g. resolution/steps values the loaded model rejects, VRAM exhaustion mid-batch, a corrupted model, or request params (steps=0, degenerate width/height) that short-circuit the pipeline.

Common situations: Requesting sizes the diffusion model does not support; too-large batch_size/count exhausting VRAM; model checkpoint partially downloaded; prompt pipeline errors that the UI would surface as a red error but the API surfaces as empty output.

Related errors


AI-assisted analysis of oobabooga/textgen@ed888c71f2 (2026-08-15). Data as JSON: /api/errors/76cbbf6d35991914. Report an issue: GitHub.