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(bfl): validate empty image list in edit handler

Chesars6fa9a0e52b2c
diff --git a/litellm/llms/black_forest_labs/image_edit/handler.py b/litellm/llms/black_forest_labs/image_edit/handler.py
index bd7809ec4b6..9bf92c874fd 100644
--- a/litellm/llms/black_forest_labs/image_edit/handler.py
+++ b/litellm/llms/black_forest_labs/image_edit/handler.py
@@ -121,7 +121,12 @@ class BlackForestLabsImageEdit:
# Transform request
# Handle image list vs single image
- image_input = image[0] if isinstance(image, list) and image else image
+ if isinstance(image, list):
+ if not image:
+ raise BlackForestLabsError(status_code=400, message="No image provided")
+ image_input = image[0]
+ else:
+ image_input = image
data, _ = self.config.transform_image_edit_request(
model=model,
prompt=prompt or "",
@@ -219,7 +224,12 @@ class BlackForestLabsImageEdit:
)
# Transform request
- image_input = image[0] if isinstance(image, list) and image else image
+ if isinstance(image, list):
+ if not image:
+ raise BlackForestLabsError(status_code=400, message="No image provided")
+ image_input = image[0]
+ else:
+ image_input = image
data, _ = self.config.transform_image_edit_request(
model=model,
prompt=prompt or "",