[GH-ISSUE #12951] issue: Chunk to big error occurs when using Gemini inline image generation #16766

Closed
opened 2026-04-19 22:36:47 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @ddddavid-he on GitHub (Apr 17, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12951

Check Existing Issues

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

Installation Method

Git Clone

Open WebUI Version

v0.6.4

Ollama Version (if applicable)

No response

Operating System

Fedora 41

Browser (if applicable)

No response

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 listed steps to reproduce the bug in detail.

Expected Behavior

I am trying to use Gemini 2.0 Flash Experimental to generate image while chatting. The WebUI should have the generated image embedded into the chat contents. For example, if I send "generated an image of an apple", gemini returns things like "This is the image: [IMAGE HERE]" or just the image itself.

Actual Behavior

In the WebUI chat interface, Gemini responses: "This is the image of an apple:" and get stucked or shows a loading interface as the below figure.

Image

By checking what the contents returned by upstream using requests, I found that there is a chunk containing

{
  "delta": {
     "content": "![image](data:image/png;base64,BASE_64_CONTENTS_OF_THE_IMAGE)",
     "role": "assistant"
  },
  "logprobs": None,
  "finish_reason": None,
  "index": 0
}

And that is what causes the Chunk too big error.

To be noticed, I am using new-api (https://github.com/QuantumNous/new-api) to enable using Gemini through OpenAI API format and to enable generate image through chat (Which is not availiable in Gemini API itself as what I know).

Steps to Reproduce

  1. Add gemini-2.0-flash-exp model to OpenWebUI through new-api .
  2. Request the model to generate an image through chat.

Logs & Screenshots

The logs of OpenWebUI goes while the OpenWebUI gets the image file from upstream:

2025-04-17 12:32:31.777 | ERROR    | asyncio.runners:run:118 - Task exception was never retrieved
future: <Task finished name='Task-140751' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1199> exception=ValueError('Chunk too big')> - {}
Traceback (most recent call last):

> File "/app/backend/open_webui/utils/middleware.py", line 1847, in post_response_handler
    await stream_body_handler(response)
          │                   └ <starlette.responses.StreamingResponse object at 0x7fc37ee0e9d0>
          └ <function process_chat_response.<locals>.post_response_handler.<locals>.stream_body_handler at 0x7fc37fdc7b00>

  File "/app/backend/open_webui/utils/middleware.py", line 1573, in stream_body_handler
    async for line in response.body_iterator:
              │       │        └ <StreamReader 27819 bytes>
              │       └ <starlette.responses.StreamingResponse object at 0x7fc37ee0e9d0>
              └ '\n'

  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__
    rv = await self.read_func()
               │    └ <member 'read_func' of 'AsyncStreamIterator' objects>
               └ <aiohttp.streams.AsyncStreamIterator object at 0x7fc39ddce890>
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline
    return await self.readuntil()
                 │    └ <function StreamReader.readuntil at 0x7fc413cbdf80>
                 └ <StreamReader 27819 bytes>
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 380, in readuntil
    raise ValueError("Chunk too big")

ValueError: Chunk too big

Additional Information

No response

Originally created by @ddddavid-he on GitHub (Apr 17, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/12951 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version v0.6.4 ### Ollama Version (if applicable) _No response_ ### Operating System Fedora 41 ### Browser (if applicable) _No response_ ### 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 listed steps to reproduce the bug in detail. ### Expected Behavior I am trying to use Gemini 2.0 Flash Experimental to generate image while chatting. The WebUI should have the generated image embedded into the chat contents. For example, if I send "generated an image of an apple", gemini returns things like "This is the image: [IMAGE HERE]" or just the image itself. ### Actual Behavior In the WebUI chat interface, Gemini responses: "This is the image of an apple:" and get stucked or shows a loading interface as the below figure. ![Image](https://github.com/user-attachments/assets/7a95fb12-3985-48aa-84ed-274a8f816a10) By checking what the contents returned by upstream using requests, I found that there is a chunk containing ```python { "delta": { "content": "![image](data:image/png;base64,BASE_64_CONTENTS_OF_THE_IMAGE)", "role": "assistant" }, "logprobs": None, "finish_reason": None, "index": 0 } ``` And that is what causes the `Chunk too big` error. To be noticed, I am using `new-api` (https://github.com/QuantumNous/new-api) to enable using Gemini through OpenAI API format and to enable generate image through chat (Which is not availiable in Gemini API itself as what I know). ### Steps to Reproduce 1. Add `gemini-2.0-flash-exp` model to `OpenWebUI` through [new-api](https://github.com/QuantumNous/new-api) . 2. Request the model to generate an image through chat. ### Logs & Screenshots The logs of OpenWebUI goes while the OpenWebUI gets the image file from upstream: ```text 2025-04-17 12:32:31.777 | ERROR | asyncio.runners:run:118 - Task exception was never retrieved future: <Task finished name='Task-140751' coro=<process_chat_response.<locals>.post_response_handler() done, defined at /app/backend/open_webui/utils/middleware.py:1199> exception=ValueError('Chunk too big')> - {} Traceback (most recent call last): > File "/app/backend/open_webui/utils/middleware.py", line 1847, in post_response_handler await stream_body_handler(response) │ └ <starlette.responses.StreamingResponse object at 0x7fc37ee0e9d0> └ <function process_chat_response.<locals>.post_response_handler.<locals>.stream_body_handler at 0x7fc37fdc7b00> File "/app/backend/open_webui/utils/middleware.py", line 1573, in stream_body_handler async for line in response.body_iterator: │ │ └ <StreamReader 27819 bytes> │ └ <starlette.responses.StreamingResponse object at 0x7fc37ee0e9d0> └ '\n' File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 52, in __anext__ rv = await self.read_func() │ └ <member 'read_func' of 'AsyncStreamIterator' objects> └ <aiohttp.streams.AsyncStreamIterator object at 0x7fc39ddce890> File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 352, in readline return await self.readuntil() │ └ <function StreamReader.readuntil at 0x7fc413cbdf80> └ <StreamReader 27819 bytes> File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 380, in readuntil raise ValueError("Chunk too big") ValueError: Chunk too big ``` ### Additional Information _No response_
GiteaMirror added the bug label 2026-04-19 22:36:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#16766