Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix image edit endpoint (#17046)

Emerson Gomes597fa4d35cf7
diff --git a/litellm/proxy/image_endpoints/endpoints.py b/litellm/proxy/image_endpoints/endpoints.py
index 16aa8f16571..a1453e10dbf 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,