From e19b44573aa9334cd5837da5426190dc7f3b6e55 Mon Sep 17 00:00:00 2001 From: shivam Date: Wed, 30 Sep 2026 21:19:31 +0000 Subject: [PATCH] refactor(proxy): build image edit defaults without mutating request data Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/image_endpoints/endpoints.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/litellm/proxy/image_endpoints/endpoints.py b/litellm/proxy/image_endpoints/endpoints.py index e20efe52bec..ea736a87b6c 100644 --- a/litellm/proxy/image_endpoints/endpoints.py +++ b/litellm/proxy/image_endpoints/endpoints.py @@ -298,13 +298,14 @@ async def image_edit_api( ######################################################### # Read request body and convert UploadFiles to BytesIO ######################################################### + form_fields: Final = coerce_numeric_form_fields( + parsed_body=await _read_request_body(request=request), + numeric_fields=IMAGE_EDIT_NUMERIC_FORM_FIELDS, + ) data: Final = { - key: value - for key, value in coerce_numeric_form_fields( - parsed_body=await _read_request_body(request=request), - numeric_fields=IMAGE_EDIT_NUMERIC_FORM_FIELDS, - ).items() - if key not in BRACKETED_FILE_FIELDS + "prompt": None, + "image": None, + **{key: value for key, value in form_fields.items() if key not in BRACKETED_FILE_FIELDS}, } image_files: Final = await batch_to_bytesio(image) mask_files: Final = await batch_to_bytesio(mask) @@ -320,12 +321,6 @@ async def image_edit_api( detail=f"'{_field}' must be provided as a multipart file upload, not a string.", ) - # Ensure prompt and image exist in data (default to None for models that don't require them) - if "prompt" not in data: - data["prompt"] = None - if "image" not in data: - data["image"] = None - data["model"] = ( model or general_settings.get("image_generation_model", None) # server default