diff --git a/app/main.py b/app/main.py index 05acbcf..159c62c 100644 --- a/app/main.py +++ b/app/main.py @@ -152,6 +152,14 @@ def _parse_json_body(raw: bytes, model_cls): async def _parse_multipart(request: Request): form = await request.form() upload = form.get("image") + if upload is None or not hasattr(upload, "read"): + # Clients following OpenAI's newer image API (e.g. LiteLLM) send the file + # under "image[]"; also accept other common field names. + for _key in ("image[]", "image[0]", "file", "input_file"): + _alt = form.get(_key) + if _alt is not None and hasattr(_alt, "read"): + upload = _alt + break # duck-typing: FastAPI 0.142+ ships its own UploadFile class, forms yield starlette's if upload is None or not hasattr(upload, "read"): raise InvalidRequest("field 'image' (file) is required")