mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[GH-ISSUE #17626] issue: "Chunk too big" error when using Google Gemini 2.5 Flash with image input #57013
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BND-1 on GitHub (Sep 21, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/17626
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.6.30
Ollama Version (if applicable)
No response
Operating System
centos
Browser (if applicable)
chrome
Confirmation
README.md.Expected Behavior
When using the Google: Gemini 2.5 Flash Image Preview model, sending a prompt that includes an image results in a "Chunk too big" error in the user interface. This prevents the model from processing the request and providing a response.
Actual Behavior
The request fails, and a red error box appears in the chat interface with the message: Chunk too big.
Steps to Reproduce
1.Navigate to the OpenWebUI chat interface.
2.Select Google: Gemini 2.5 Flash Image Preview from the model selection dropdown.
3.Upload an image or provide an image along with a text prompt (e.g., "draw a puppy").
4.Send the message to the model.
5.Observe the error message displayed in the chat window.
Logs & Screenshots
Additional Information
This error suggests a potential issue with how large inputs, specifically image data, are chunked or sent to the backend/model API. It seems to be hitting a size limit somewhere in the data transmission pipeline. This issue currently blocks the use of the vision capabilities for the Gemini 2.5 Flash model within OpenWebUI.
@yborunov commented on GitHub (Sep 26, 2025):
same issue. Any update?
@cj1324 commented on GitHub (Sep 26, 2025):
same issue. Any update?
@ShirasawaSama commented on GitHub (Sep 26, 2025):
We previously discovered that when SSE single-line data is extremely large (likely exceeding 16KB), directly using Python's asynchronous iterator to traverse aiohttp's
response.contentforces the use of aiohttp's built-in buffer size, which cannot be configured.https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py#L947
Our solution was to replace it with our own asynchronous iterator, calling AsyncContentStream's
iter_chunks()method to iterate over all bytes. We actively split each line using the\nsymbol and then yield the data for each line.This approach avoids the constraints of aiohttp's buffer size. Unfortunately, I don't have permission to publish this specific code, so I can only share the underlying solution concept.
cc @tjbck
@OakerO commented on GitHub (Sep 29, 2025):
Maybe someone should publish it then?
@rgaricano commented on GitHub (Sep 29, 2025):
approach, for
37d1c85c99/backend/open_webui/routers/openai.py (L929-L977)By using iter_chunked() or iter_any(), we avoid this line-buffering behavior and process data in smaller, manageable chunks regardless of line boundaries.
We can choose iter_any() for immediate data availability or iter_chunked() with a specific chunk size (like 8192 bytes) for more predictable memory usage.
@ShirasawaSama commented on GitHub (Sep 29, 2025):
@rgaricano
In fact, many of my MCP SSE calls exceed 500KB, and occasionally even surpass 50MB per line. Consequently, my code includes logic to skip lines exceeding a certain length.
However, I don't think this is a common scenario, so it may not necessarily need to be implemented.
Additionally, we cannot directly call
iter_anyoriter_chunkedand then yield the chunk directly; this approach is incorrect.Because a single chunk may contain multiple lines, or a single line may be split across multiple chunks. Therefore, we must concatenate multiple chunks and use the
\ncharacter to separate lines of text. If the current chunk's terminator is not a\ncharacter, we can assume that the next chunk or subsequent chunks still contain the remainder of the current line.@rgaricano commented on GitHub (Sep 29, 2025):
then maybe something like this:
@ddddavid-he commented on GitHub (Oct 8, 2025):
Any update?
@ShirasawaSama commented on GitHub (Oct 11, 2025):
Any update? 🤔
@COCONUTwwater commented on GitHub (Oct 17, 2025):
Any update? 🤔
@Classic298 commented on GitHub (Oct 17, 2025):
PR welcome afaik
@GeoffreyLng commented on GitHub (Oct 21, 2025):
Same issue, any updates ?
@Classic298 commented on GitHub (Oct 21, 2025):
No update yet, PR welcome
@mweichert commented on GitHub (Oct 25, 2025):
Also experiencing this issue with
gemini-2.5-flash-lite.@NopeNix commented on GitHub (Oct 30, 2025):
same here
@zuogod commented on GitHub (Nov 3, 2025):
Any update? 🤔
@Classic298 commented on GitHub (Nov 3, 2025):
PR welcome
@ShirasawaSama commented on GitHub (Nov 3, 2025):
#18884
@silentoplayz commented on GitHub (Nov 5, 2025):
Related - https://github.com/open-webui/open-webui/issues/16935
@Classic298 commented on GitHub (Nov 6, 2025):
should be fixed in dev
@ShirasawaSama commented on GitHub (Nov 7, 2025):
@Classic298 Not yet resolved
@ddddavid-he commented on GitHub (Nov 7, 2025):
Same situation on my machine
@DeusMaximus commented on GitHub (Nov 7, 2025):
Still happening through LiteLLM
@GeoffreyLng commented on GitHub (Nov 7, 2025):
Still occuring when using LiteLLM
@ddkedr commented on GitHub (Nov 7, 2025):
@Classic298 can we reopen it? Still does not work when using LiteLLM
@Classic298 commented on GitHub (Nov 7, 2025):
I am aware, but that is as it looks to me, an issue with LiteLLM. I raised it with them, hopefully they can address it soon.
(Add Gemini 2.5 Flash Image in the Image configs)
@AlexZorzi commented on GitHub (Nov 7, 2025):
@Classic298 for me its not working either, im not using LiteLLM, connected directly to OpenRouter.
@Classic298 commented on GitHub (Nov 7, 2025):
Do not talk to the model - add it in the image config as I said. - and not sure openrouter is supported yet, but the official Gemini API is supported.
@ShirasawaSama commented on GitHub (Nov 10, 2025):
Hey everyone, the “Chunk too big” issue has been fixed in the latest dev branch.
You can enable it using the following environment variable:
And the issue where models in OpenRouter cannot output images will be fixed in this pull request #19073.
@tjbck commented on GitHub (Nov 10, 2025):
@silentoplayz @Classic298 Documentation updated wanted here!
@silentoplayz commented on GitHub (Nov 10, 2025):
What is enabled when I set this as an environment variable for my Open WebUI instance? Is it necessary to have this environment variable set at all for image generation/editing to work properly using Google Gemini 2.5 Flash in Open WebUI?
@ShirasawaSama commented on GitHub (Nov 10, 2025):
Related PR #19076
@ShirasawaSama commented on GitHub (Nov 10, 2025):
This value is recommended to be greater than 5MB. As a reference, a GPT image typically outputs around 3.5MB of Base64-encoded image data. Our production environment is configured to 8MB (since we implemented sending socket.io data via SSE, which prevents massive single-line data from causing Redis cluster crashes; therefore, I do not recommend setting this value too high).
A value greater than 2.5MB must be set to display images generated by the nano banana model.
@Classic298 commented on GitHub (Nov 10, 2025):
documted
@usef814 commented on GitHub (Nov 11, 2025):
This will be great, I have been having the same issue ("Chunk too big") between openwebui and openrouter when trying to generate an image. . In the meantime using the integration with comfyui, works ok but text just isn't great when compared to gpt-5 image or many others.
@Dzenn00 commented on GitHub (Nov 11, 2025):
Hi, we used the specified variable, but we get this output without a picture. Most often, the model simply sends ` symbol
@M0n7y5 commented on GitHub (Nov 11, 2025):
CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE
does not help at all, i tested nano banana and chatgpt 5 image, still chunk too big error
@Classic298 commented on GitHub (Nov 11, 2025):
@M0n7y5 that env var doesn't exist yet.
It was just introduced on the dev branch and will be shipped in the next version
@ShirasawaSama commented on GitHub (Nov 12, 2025):
@Dzenn00 Are you using OpenRouter?
@Dzenn00 commented on GitHub (Nov 12, 2025):
@ShirasawaSama yes
@M0n7y5 commented on GitHub (Nov 12, 2025):
Ah i see, my bad then. I'll wait for the update.
@ShirasawaSama commented on GitHub (Nov 19, 2025):
Hello to all users of OpenRouter here. The
devbranch now supports image output in the Nano Banana model format for OpenRouter. If you have some free time, please git checkout to the latest dev branch for testing. Thanks! #19073If you encounter any issues, feel free to reply directly below and I'll make adjustments immediately. Of course, other third-party model providers are also welcome to test it!
Thank you all for your testing—it helps make the feature more stable!
@silentoplayz commented on GitHub (Nov 19, 2025):
Tested and working on the
devbranch for me. Amazing work!@zuli12-dev commented on GitHub (Nov 22, 2025):
i just tested with the latest docker dev image (ghcr.io/open-webui/open-webui:git-b32f781) and CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE=10485760 but i still see the same error
@ShirasawaSama commented on GitHub (Nov 23, 2025):
Have you tried setting this value to a larger number, such as 100000000? Or could you tell me who your service provider is? (e.g., OpenRouter)
Additionally, what method did you use to set environment variables in Docker?
@YorhaL commented on GitHub (Nov 23, 2025):
Use
devDocker + CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE + LiteLLM + Vertex Gemini 3 Pro Image@zuli12-dev commented on GitHub (Nov 23, 2025):
Yes i just tried both, it seems it was some CORS quirk, it generates the images just fine now, many thanks!
@ddkedr commented on GitHub (Nov 24, 2025):
Is this me or the first response gives me 2 same picture instead of one? Nano Banana 2/Pro
@ShirasawaSama commented on GitHub (Nov 24, 2025):
@ddkedr Could you tell me who your service provider is? (e.g., OpenRouter)
@M0n7y5 commented on GitHub (Nov 24, 2025):
I have the same issue, it gives me 3 pictures that are completely same. I am using OpenRouter.
@bibendi commented on GitHub (Nov 24, 2025):
Why do we need to configure the chunk size using an environment variable? Is this a bad practice inspired by LibreChat? :) I noticed there are so many environment variables in the latest release.
@ShirasawaSama commented on GitHub (Nov 24, 2025):
I currently suspect that OpenRouter may have altered its API structure or that subsequent code changes have disrupted my code. I will attempt to reproduce and fix the issue tomorrow.
@ShirasawaSama commented on GitHub (Nov 24, 2025):
@bibendi Actually, this switch was enabled by default in my initial code commit, but the project owner later disabled it by default during refactoring. They probably wanted to wait until functional testing confirmed stability before enabling it by default or not. :)
@ShirasawaSama commented on GitHub (Nov 25, 2025):
@zuli12-dev @ddkedr @M0n7y5 Hello guys, I'm very sorry, but I'm unable to reproduce this issue (I'm using the latest v0.6.38 version + OpenRouter). I've also tried both the “Google: Nano Banana Pro (Gemini 3 Pro Image Preview)” and “Google: Gemini 2.5 Flash Image (Nano Banana)” models, but encountered no problems whatsoever.
Here are my environment variables:
Could you provide more context? For example, is the built-in image editing feature in OpenWebUI enabled?
@ZanMarolt commented on GitHub (Nov 25, 2025):
It works for me but, after my chat gets longer it stops showing the images, it works if I open up a new chat and add a new prompt. I haven't used it without the open router so it could also very well be the same behavior there as well 🤷
@NopeNix commented on GitHub (Dec 2, 2025):
I'm using it via Replicate and it works fine for me, whoever fix that: Thanks ♥️
@ShirasawaSama commented on GitHub (Dec 4, 2025):
Hello everyone, regarding the 4K mode for the new model (Gemini 3 Image Pro), images may occasionally exceed 10MB in size. Therefore, I personally recommend configuring
CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE=20971520(20MB).@dekotur commented on GitHub (Dec 5, 2025):
Hello everyone. Windows 10 / Python version / Chrome / Openrouter. Faced this issue too.
Fixed using
set CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE=16777216parameter.Now I too have issue with 1-2 image duplicates:
@Classic298 commented on GitHub (Dec 5, 2025):
@dekotur turn off image edit in admin panel
@M0n7y5 commented on GitHub (Dec 8, 2025):
That does not help. In my case it was never turned on and i still got the same issue with openrouter.
@ShirasawaSama commented on GitHub (Dec 9, 2025):
Could you please take a screenshot of the "image settings" page in the admin panel? Currently, I personally believe this is the only setting that could potentially cause multiple images to appear.
@M0n7y5 commented on GitHub (Dec 11, 2025):
@ShirasawaSama
@spammenotinoz commented on GitHub (Dec 18, 2025):
Indeed it does fix the issue, but also breaks streaming calls to the api endpoint.. :(
Disabled streaming under advanced properties, didn't fix the issue thought it would though.
To clarify I am referring to the issue generating images with the chat models, not the "create image" tool which is working fine.
@ShirasawaSama commented on GitHub (Dec 18, 2025):
Fixed in dev #19829
@spammenotinoz commented on GitHub (Dec 19, 2025):
Thank-you, it worked.
Was having a silly moment, was about to say #19829 did not fix the "Chunk too big" issue, then realise it was to address the streaming issue when CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE=20971520
Thank-you, no errors so far in testing,
@Steve-Li-1998 commented on GitHub (Dec 22, 2025):
Is this problem really fixed? I’ve just upgraded to version 0.6.42, but it appears that the issue still persists.
@spammenotinoz commented on GitHub (Dec 22, 2025):
You also need to set CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE=20971520
@Steve-Li-1998 commented on GitHub (Dec 22, 2025):
Where should this parameter be configured?
@spammenotinoz commented on GitHub (Dec 22, 2025):
Environment Variable and then re-launch
@Steve-Li-1998 commented on GitHub (Dec 22, 2025):
Thank you so much!
@Steve-Li-1998 commented on GitHub (Dec 22, 2025):
And I found a problem that the thought part of the answer may never returned
@DaAitch commented on GitHub (Jan 21, 2026):
The documentation says not setting
CHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZEis equal to "no limit", butCHAT_STREAM_RESPONSE_CHUNK_MAX_BUFFER_SIZE=20971520fixed it (Open WebUI v0.7.2)How is that consistent 😄 ?
Anyway thanks for making this possible 👍
@Classic298 commented on GitHub (Jan 21, 2026):
Good catch please open an issue in docs repository i will take a look @DaAitch
@tzhouML commented on GitHub (Feb 19, 2026):
I don't think it's a great experiencde that users should have to stumble on this issue thread to figure out how to get image chat models working. Thanks everyone.
@Classic298 commented on GitHub (Feb 19, 2026):
@tzhouML Thats why its documented on the docs on the How-To Tutorials for image generation and in the Troubleshooting Guides in the docs as well