From 00cf9550afcd3d7b3ea80864f5f9d8047537b47e Mon Sep 17 00:00:00 2001 From: Chesars Date: Wed, 4 Mar 2026 18:16:21 -0300 Subject: [PATCH] fix(bfl): handle URL and file path inputs in image edit _read_image_bytes was not handling string inputs (URLs or file paths), causing a TypeError when passing a URL as the image source. --- .../black_forest_labs/image_edit/transformation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/litellm/llms/black_forest_labs/image_edit/transformation.py b/litellm/llms/black_forest_labs/image_edit/transformation.py index 1c381d118ed..95e3c946cc8 100644 --- a/litellm/llms/black_forest_labs/image_edit/transformation.py +++ b/litellm/llms/black_forest_labs/image_edit/transformation.py @@ -184,6 +184,16 @@ class BlackForestLabsImageEditConfig(BaseImageEditConfig): elif isinstance(image, list): # If it's a list, take the first image return self._read_image_bytes(image[0]) + elif isinstance(image, str): + if image.startswith(("http://", "https://")): + # Download image from URL + import httpx as _httpx + response = _httpx.get(image) + return response.content + else: + # Assume it's a file path + with open(image, "rb") as f: + return f.read() elif hasattr(image, "read"): # File-like object pos = getattr(image, "tell", lambda: 0)()