[GH-ISSUE #14394] Stable Diffusion image generation fails with TypeError: a bytes-like object is required, not 'dict' #32763

Closed
opened 2026-04-25 06:37:32 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @egr12345 on GitHub (May 27, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/14394

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Pip Install

Open WebUI Version

0611

Ollama Version (if applicable)

No response

Operating System

Win11

Browser (if applicable)

Chrome

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

Image gen

Actual Behavior

Description:
After updating OpenWebUI, image generation via local Stable Diffusion API (A1111) stopped working. The error occurs when the backend expects raw image bytes but receives a JSON/dict response from the API.

Steps to Reproduce:

  1. Enable Stable Diffusion integration in OpenWebUI settings.
  2. Try to generate an image via chat.
  3. Error appears:
    TypeError: a bytes-like object is required, not 'dict'
    File "open_webui/routers/images.py", line 457, in upload_image
    file=io.BytesIO(image_data)  # Fails because image_data is a dict
    

Expected Behavior:
OpenWebUI should handle the Stable Diffusion API response correctly (either by accepting JSON with images field or raw bytes).

Proposed Fix:
Modify upload_image() in images.py to parse API responses properly. Example for base64 responses:

# Before (fails with dict):
file = UploadFile(file=io.BytesIO(image_data), ...)

# After (handles dict/base64):
if isinstance(image_data, dict) and "images" in image_data:
    image_data = base64.b64decode(image_data["images"][0].split(",")[1])
file = UploadFile(file=io.BytesIO(image_data), ...)

Additional Context:

  • Works fine in v0.6.10 (older version processes bytes correctly).
  • Stable Diffusion API (A1111) returns JSON like:
    {"images": ["data:image/png;base64,..."]}
    

Steps to Reproduce

Install last versio 0611

Logs & Screenshots

No

Additional Information

No response

Originally created by @egr12345 on GitHub (May 27, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/14394 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Pip Install ### Open WebUI Version 0611 ### Ollama Version (if applicable) _No response_ ### Operating System Win11 ### Browser (if applicable) Chrome ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior Image gen ### Actual Behavior **Description**: After updating OpenWebUI, image generation via local Stable Diffusion API (A1111) stopped working. The error occurs when the backend expects raw image bytes but receives a JSON/dict response from the API. **Steps to Reproduce**: 1. Enable Stable Diffusion integration in OpenWebUI settings. 2. Try to generate an image via chat. 3. Error appears: ```python TypeError: a bytes-like object is required, not 'dict' File "open_webui/routers/images.py", line 457, in upload_image file=io.BytesIO(image_data) # Fails because image_data is a dict ``` **Expected Behavior**: OpenWebUI should handle the Stable Diffusion API response correctly (either by accepting JSON with `images` field or raw bytes). **Proposed Fix**: Modify `upload_image()` in `images.py` to parse API responses properly. Example for base64 responses: ```python # Before (fails with dict): file = UploadFile(file=io.BytesIO(image_data), ...) # After (handles dict/base64): if isinstance(image_data, dict) and "images" in image_data: image_data = base64.b64decode(image_data["images"][0].split(",")[1]) file = UploadFile(file=io.BytesIO(image_data), ...) ``` **Additional Context**: - Works fine in **v0.6.10** (older version processes bytes correctly). - Stable Diffusion API (A1111) returns JSON like: ```json {"images": ["data:image/png;base64,..."]} ``` ### Steps to Reproduce Install last versio 0611 ### Logs & Screenshots No ### Additional Information _No response_
GiteaMirror added the bug label 2026-04-25 06:37:32 -05:00
Author
Owner

@tjbck commented on GitHub (May 27, 2025):

This has been addressed in latest main and dev, for pip install you'll have to wait until 0.6.12.

<!-- gh-comment-id:2912313111 --> @tjbck commented on GitHub (May 27, 2025): This has been addressed in latest main and dev, for pip install you'll have to wait until 0.6.12.
Author
Owner

@tjbck commented on GitHub (May 28, 2025):

Status: Open.
#14419 In open-webui/open-webui;

<!-- gh-comment-id:2917860848 --> @tjbck commented on GitHub (May 28, 2025): Status: Open. #14419 In open-webui/open-webui;
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#32763