invoke-ai/InvokeAI · error · HTTPException

Image '{body.image_name}' not found

Error message

Image '{body.image_name}' not found

What it means

The image_to_prompt endpoint catches ImageFileNotFoundException raised while fetching body.image_name from InvokeAI's image store and converts it into HTTP 404 with detail "Image '{body.image_name}' not found". The image record or its underlying file does not exist.

Source

Thrown at invokeai/app/api/routers/utilities.py:324

        prompt = await asyncio.to_thread(
            _run_image_to_prompt,
            body.image_name,
            body.model_key,
            body.instruction,
            body.task_id,
            current_user.user_id,
        )
        if body.task_id is not None:
            events.emit_llm_task_complete(task_id=body.task_id, user_id=current_user.user_id)
        return ImageToPromptResponse(prompt=prompt)
    except UnknownModelException:
        if body.task_id is not None:
            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error="Model not found")
        raise HTTPException(status_code=404, detail=f"Model '{body.model_key}' not found")
    except ImageFileNotFoundException:
        if body.task_id is not None:
            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error="Image not found")
        raise HTTPException(status_code=404, detail=f"Image '{body.image_name}' not found")
    except (ValueError, TypeError) as e:
        if body.task_id is not None:
            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error=str(e))
        raise HTTPException(status_code=422, detail=str(e))
    except Exception as e:
        if body.task_id is not None:
            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error=str(e))
        logger.error(f"Error generating prompt from image: {e}")
        raise HTTPException(status_code=500, detail=str(e))

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Verify the image exists via GET /api/v1/images/{image_name} before calling image_to_prompt
  2. Re-upload or regenerate the image if it was deleted/purged
  3. Correct the image_name in the calling script (copy the exact UUID name from the gallery API)
  4. Check that the images directory on disk still contains the file if the record exists

Example fix

# before
resp = requests.post(url, json={"image_name": deleted_name, "model_key": key})
# after
if requests.get(f"{base}/api/v1/images/{image_name}").status_code == 200:
    resp = requests.post(url, json={"image_name": image_name, "model_key": key})
Defensive patterns

Strategy: validation

Validate before calling

r = requests.get(f"{base}/api/v1/images/{image_name}")
assert r.status_code == 200, f"image {image_name} missing"

Try / catch

try:
    resp = requests.post(f"{base}/utilities/image_to_prompt", json={"image_name": img, "model_key": key})
    resp.raise_for_status()
except requests.HTTPError as e:
    if e.response.status_code == 404 and "Image" in e.response.text:
        reupload_or_pick_new_image()

Prevention

When it happens

Trigger: POST /utilities/image_to_prompt with an image_name that was deleted, purged from disk (deleted files setting), never existed, or belongs to another user/board the caller cannot see.

Common situations: Client kept a reference after the image was deleted via the UI; gallery cleaned up old images; name typo or wrong image-UUID format in an automation script; multiuser install where the image belongs to a different account.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/555e66887a93c8b6. Report an issue: GitHub.