From 6214cc77a871b3cee691057553cf8ee64e5d0771 Mon Sep 17 00:00:00 2001 From: Shaman Date: Tue, 6 Oct 2026 03:28:11 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=D1=85=D0=BE=D0=B4=D0=BD=D0=BE=D0=B5=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20edits=20=D0=BF=D0=BE=D0=B4=20=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D0=BE=D0=BB=D1=8F=20image[]=20(=D1=81?= =?UTF-8?q?=D0=BE=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8=D0=BC=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D1=81=20LiteLLM)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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")