odysseus-dev/odysseus · error · HTTPException

{type(_pipe).__name__} does not support image edits. Use /v1

Error message

{type(_pipe).__name__} does not support image edits. Use /v1/images/generations with this model.

What it means

Raised by the /v1/images/edits endpoint in scripts/diffusion_server.py when the currently loaded diffusers pipeline class does not accept an 'image' or 'input_images' argument (checked via _pipeline_accepts_arg). It means the served model is text-to-image only (e.g. a pure StableDiffusionPipeline) while the caller invoked the OpenAI-style edits endpoint, which requires an img2img/inpaint pipeline. The server refuses the call with HTTP 400 instead of letting the pipeline fail with a confusing TypeError.

Source

Thrown at scripts/diffusion_server.py:778


@app.post("/v1/images/edits")
async def edit_image(
    prompt: str = Form(...),
    image: UploadFile = File(...),
    model: str = Form(""),
    n: int = Form(1),
    size: str = Form("1024x1024"),
    quality: str = Form("medium"),
    response_format: str = Form("b64_json"),
    request_id: str = Form(""),
):
    if _pipe is None:
        return {"error": "Model not loaded"}
    accepts_image = _pipeline_accepts_arg("image")
    accepts_input_images = _pipeline_accepts_arg("input_images")
    if not accepts_image and not accepts_input_images:
        raise HTTPException(
            status_code=400,
            detail=f"{type(_pipe).__name__} does not support image edits. Use /v1/images/generations with this model.",
        )

    from PIL import Image as PILImage, ImageOps

    width, height = _parse_size(size)
    steps = _quality_steps(quality)
    request_id = _start_progress(request_id, steps * max(1, min(int(n or 1), 4)), prompt, "edit")
    raw = await image.read()
    init_image = PILImage.open(io.BytesIO(raw)).convert("RGB")
    if width > 0 and height > 0:
        init_image = ImageOps.fit(init_image, (width, height), method=PILImage.LANCZOS, centering=(0.5, 0.5))

    logger.info(f"Editing image: {prompt[:80]}... ({width}x{height}, {steps} steps)")
    start = time.time()
    images = []
    total_images = max(1, min(int(n or 1), 4))

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Switch the request to POST /v1/images/generations, which the loaded pipeline supports, passing the prompt only
  2. Relaunch the server with an edit-capable model (e.g. an '-inpaint' or img2img variant repo id) so the pipeline accepts an image argument
  3. Verify which pipeline class is loaded (type(_pipe).__name__ in the error) and pick a repo whose class supports edits
  4. If you maintain the server, add a /v1/models capability field so clients can detect edit support before calling

Example fix

# before
client.images.edit(image=open('cat.png','rb'), prompt='add a hat')
# after (generation-only pipeline)
client.images.generate(prompt='a cat wearing a hat')
Defensive patterns

Strategy: validation

Validate before calling

# Probe edit support before calling edits
import requests
caps = requests.get(f"{base}/v1/models").json()
# servers do not advertise caps; safest check: try generations, or inspect pipeline name via any diagnostics endpoint
edit_capable = False  # assume not unless server documents it

Type guard

def supports_edits(pipeline) -> bool:
    import inspect
    params = inspect.signature(pipeline.__call__).parameters
    return 'image' in params or 'input_images' in params

Try / catch

from fastapi import HTTPException
try:
    resp = client.images.edit(image=f, prompt=p)
except HTTPException as e:  # or openai.APIStatusError with 400
    if 'does not support image edits' in str(e):
        resp = client.images.generate(prompt=reconstructed_prompt)

Prevention

When it happens

Trigger: POST to /v1/images/edits with a multipart 'image' file while the loaded pipeline is a generation-only class (its __call__/forward signature has no 'image' or 'input_images' parameter). Typical after loading e.g. 'stable-diffusion-2-1' base rather than an '*-inpaint' or img2img-capable variant.

Common situations: Server was launched with a base text-to-image checkpoint; client (OpenAI SDK images.edit) is reused against a local endpoint; model was switched at runtime to a non-edit pipeline; typo in the model repo id resolving to the base variant.

Related errors


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/9c3c54dfdc07c762. Report an issue: GitHub.