From bddadafa074fea5641bd414e21a19b9fb91bfdc0 Mon Sep 17 00:00:00 2001 From: HW Date: Mon, 1 Jun 2026 19:33:24 +0200 Subject: [PATCH] fix(images): pass content_type=None to r.json() to accept non-standard MIME types (#24838) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aiohttp's ClientResponse.json() validates the Content-Type header against 'application/json' by default and raises ContentTypeError for any other value — including 'application/x-ndjson', which Ollama returns for its OpenAI-compatible /v1/images/generations endpoint. Pass content_type=None to skip this check while keeping all other parsing behaviour unchanged. The fix covers image generation (openai, gemini, automatic1111 engines) and image editing (openai, gemini engines). --- backend/open_webui/routers/images.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py index 4eced8cb0b..ba824f33c1 100644 --- a/backend/open_webui/routers/images.py +++ b/backend/open_webui/routers/images.py @@ -626,7 +626,7 @@ async def image_generations( ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as r: r.raise_for_status() - res = await r.json() + res = await r.json(content_type=None) images = [] @@ -676,7 +676,7 @@ async def image_generations( ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as r: r.raise_for_status() - res = await r.json() + res = await r.json(content_type=None) images = [] @@ -785,7 +785,7 @@ async def image_generations( headers={'authorization': get_automatic1111_api_auth(request)}, ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as r: - res = await r.json() + res = await r.json(content_type=None) log.debug(f'res: {res}') images = [] @@ -960,7 +960,7 @@ async def image_edits( ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as r: r.raise_for_status() - res = await r.json() + res = await r.json(content_type=None) images = [] for image in res['data']: @@ -1015,7 +1015,7 @@ async def image_edits( ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as r: r.raise_for_status() - res = await r.json() + res = await r.json(content_type=None) images = [] for image in res['candidates']: