From 597fa4d35cf792eb03e1492445a88808ce34d150 Mon Sep 17 00:00:00 2001 From: Emerson Gomes Date: Mon, 24 Nov 2025 22:52:35 -0600 Subject: [PATCH] Fix image edit endpoint (#17046) * Fix image edit endpoint * Update litellm/proxy/image_endpoints/endpoints.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- litellm/proxy/image_endpoints/endpoints.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/image_endpoints/endpoints.py b/litellm/proxy/image_endpoints/endpoints.py index 16aa8f1657..a1453e10db 100644 --- a/litellm/proxy/image_endpoints/endpoints.py +++ b/litellm/proxy/image_endpoints/endpoints.py @@ -215,9 +215,11 @@ async def image_generation( async def image_edit_api( request: Request, fastapi_response: Response, - image: List[UploadFile] = File(...), - mask: Optional[List[UploadFile]] = File(None), user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth), + image: Optional[List[UploadFile]] = File(None), + image_array: Optional[List[UploadFile]] = File(None, alias="image[]"), + mask: Optional[List[UploadFile]] = File(None), + mask_array: Optional[List[UploadFile]] = File(None, alias="mask[]"), model: Optional[str] = None, ): """ @@ -233,6 +235,18 @@ async def image_edit_api( -F 'prompt=Create a studio ghibli image of this' ``` """ + if image is not None and image_array is not None: + raise HTTPException(status_code=422, detail="Cannot specify both 'image' and 'image[]'") + if mask is not None and mask_array is not None: + raise HTTPException(status_code=422, detail="Cannot specify both 'mask' and 'mask[]'") + if image is None and image_array is not None: + image = image_array + if mask is None and mask_array is not None: + mask = mask_array + + if image is None: + raise HTTPException(status_code=422, detail="Field required: image") + from litellm.proxy.proxy_server import ( _read_request_body, general_settings,