[GH-ISSUE #21301] issue: Wrong request header in the Image Generate function. #34965

Closed
opened 2026-04-25 09:08:53 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Randark-JMT on GitHub (Feb 11, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21301

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.7.2

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04

Browser (if applicable)

Firefox 147.0.3

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

I used a routing transformation technique to convert the image generation model from a third-party vendor into an interface that conforms to the OpenAI API definition and provides it to Open-WebUI. Theoretically, this should work correctly and provide image generation capabilities.

Actual Behavior

However, Open-WebUI used the 'Content-Type': 'application/json' request header for the returned image URL, causing the model provider to refuse to respond.

Steps to Reproduce

  1. use https://github.com/QuantumNous/new-api project to convert model wan2.6-t2i from Aliyun Bailian to a custom API which compliant with OpenAPI routing specifications
  2. try to use this api
  3. The system displayed the message: "An error occurred while generating an image".

Logs & Screenshots

Backend Log:

2026-02-11 09:09:27.216 | INFO     | uvicorn.protocols.http.httptools_impl:send:483 - 112.49.200.164:0 - "POST /api/chat/completions HTTP/1.1" 200
2026-02-11 09:09:27.269 | INFO     | uvicorn.protocols.http.httptools_impl:send:483 - 112.49.200.164:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200
2026-02-11 09:09:41.422 | ERROR    | open_webui.routers.images:get_image_data:499 - Error loading image data: 403 Client Error: Forbidden for url: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f9f0-09b9-#######
Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/site-packages/uvicorn/__main__.py", line 4, in <module>
    uvicorn.main()
    │       └ <Command main>
    └ <module 'uvicorn' from '/usr/local/lib/python3.11/site-packages/uvicorn/__init__.py'>
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           │    │     │       └ {}
           │    │     └ ()
           │    └ <function Command.main at 0x7fe0de99ee80>
           └ <Command main>
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
         │    │      └ <click.core.Context object at 0x7fe0df866850>
         │    └ <function Command.invoke at 0x7fe0de99eb60>
         └ <Command main>
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │   │      │    │           │   └ {'host': '0.0.0.0', 'port': 8080, 'forwarded_allow_ips': '*', 'workers': 1, 'app': 'open_webui.main:app', 'uds': None, 'fd': ...
           │   │      │    │           └ <click.core.Context object at 0x7fe0df866850>
           │   │      │    └ <function main at 0x7fe0de658b80>
           │   │      └ <Command main>
           │   └ <function Context.invoke at 0x7fe0de99dda0>
           └ <click.core.Context object at 0x7fe0df866850>
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
           │         │       └ {'host': '0.0.0.0', 'port': 8080, 'forwarded_allow_ips': '*', 'workers': 1, 'app': 'open_webui.main:app', 'uds': None, 'fd': ...
           │         └ ()
           └ <function main at 0x7fe0de658b80>
  File "/usr/local/lib/python3.11/site-packages/uvicorn/main.py", line 424, in main
    run(
    └ <function run at 0x7fe0de8f94e0>
  File "/usr/local/lib/python3.11/site-packages/uvicorn/main.py", line 594, in run
    server.run()
    │      └ <function Server.run at 0x7fe0de8f8d60>
    └ <uvicorn.server.Server object at 0x7fe0dea7ad50>
  File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 67, in run
    return asyncio_run(self.serve(sockets=sockets), loop_factory=self.config.get_loop_factory())
           │           │    │             │                      │    │      └ <function Config.get_loop_factory at 0x7fe0dea814e0>
           │           │    │             │                      │    └ <uvicorn.config.Config object at 0x7fe0de666b50>
           │           │    │             │                      └ <uvicorn.server.Server object at 0x7fe0dea7ad50>
           │           │    │             └ None
           │           │    └ <function Server.serve at 0x7fe0de8f8e00>
           │           └ <uvicorn.server.Server object at 0x7fe0dea7ad50>
           └ <function asyncio_run at 0x7fe0de991e40>
  File "/usr/local/lib/python3.11/site-packages/uvicorn/_compat.py", line 30, in asyncio_run
    return runner.run(main)
           │      │   └ <coroutine object Server.serve at 0x7fe0de6558a0>
           │      └ <function Runner.run at 0x7fe0dec40fe0>
           └ <asyncio.runners.Runner object at 0x7fe0de8aed90>
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           │    │     │                  └ <Task pending name='Task-1' coro=<Server.serve() running at /usr/local/lib/python3.11/site-packages/uvicorn/server.py:71> wai...
           │    │     └ <cyfunction Loop.run_until_complete at 0x7fe0de6cc040>
           │    └ <uvloop.Loop running=True closed=False debug=False>
           └ <asyncio.runners.Runner object at 0x7fe0de8aed90>

  File "/app/backend/open_webui/main.py", line 1710, in process_chat
    form_data, metadata, events = await process_chat_payload(
    │          │                        └ <function process_chat_payload at 0x7fe061df7d80>
    │          └ {'user_id': '290239f3-e91c-4e8e-9dbc-dd503bb9a0d8', 'chat_id': 'dd1c9f9c-abdb-4b4b-b772-615d6ec91f85', 'message_id': 'a9f8e32...
    └ {'stream': True, 'model': 'qwen3-max-2026-01-23', 'messages': [{'role': 'user', 'content': '生成一个素描画,一只可爱的猫咪坐在窗台上,窗外是星空,数字艺术风格...

  File "/app/backend/open_webui/utils/middleware.py", line 1588, in process_chat_payload
    form_data = await chat_image_generation_handler(
                      └ <function chat_image_generation_handler at 0x7fe061df7b00>

  File "/app/backend/open_webui/utils/middleware.py", line 1130, in chat_image_generation_handler
    images = await image_generations(
                   └ <function image_generations at 0x7fe063f4e5c0>

  File "/app/backend/open_webui/routers/images.py", line 639, in image_generations
    image_data, content_type = get_image_data(image_url, headers)
                               │              │          └ {'Authorization': 'Bearer sk-gtL0gS#############ZwuDYhI3SwmrD', 'Content-Type': 'application/json'}
                               │              └ 'https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f9f0-09b9-4dc7-8485-476514867d02.png?Ex...
                               └ <function get_image_data at 0x7fe063f4e020>

> File "/app/backend/open_webui/routers/images.py", line 482, in get_image_data
    r.raise_for_status()
    │ └ <function Response.raise_for_status at 0x7fe0dc32c5e0>
    └ <Response [403]>

  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1026, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
          │         │                        └ <Response [403]>
          │         └ '403 Client Error: Forbidden for url: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f9...
          └ <class 'requests.exceptions.HTTPError'>

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f###14867d02.png?###

Additional Information

This is my custom API's response

{
    "data": [
        {
            "url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/7a/2####################################",
            "b64_json": "",
            "revised_prompt": ""
        }
    ],
    "created": 1770802551,
    "metadata": {
        "output": {
            "choices": [
                {
                    "finish_reason": "stop",
                    "message": {
                        "content": [
                            {
                                "image": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/7a/2####################################",
                                "type": "image"
                            }
                        ],
                        "role": "assistant"
                    }
                }
            ],
            "finished": true
        },
        "usage": {
            "image_count": 1,
            "input_tokens": 0,
            "output_tokens": 0,
            "size": "1024*1024",
            "total_tokens": 0
        },
        "request_id": "65555544-5157-4765-9e1d-0d06a9c550cf"
    }
}
Originally created by @Randark-JMT on GitHub (Feb 11, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/21301 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.7.2 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04 ### Browser (if applicable) Firefox 147.0.3 ### 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 I used a routing transformation technique to convert the image generation model from a third-party vendor into an interface that conforms to the OpenAI API definition and provides it to Open-WebUI. Theoretically, this should work correctly and provide image generation capabilities. ### Actual Behavior However, Open-WebUI used the 'Content-Type': 'application/json' request header for the returned image URL, causing the model provider to refuse to respond. ### Steps to Reproduce 1. use https://github.com/QuantumNous/new-api project to convert model `wan2.6-t2i` from Aliyun Bailian to a custom API which compliant with OpenAPI routing specifications 2. try to use this api 3. The system displayed the message: "An error occurred while generating an image". ### Logs & Screenshots Backend Log: ```log 2026-02-11 09:09:27.216 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 112.49.200.164:0 - "POST /api/chat/completions HTTP/1.1" 200 2026-02-11 09:09:27.269 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 112.49.200.164:0 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 2026-02-11 09:09:41.422 | ERROR | open_webui.routers.images:get_image_data:499 - Error loading image data: 403 Client Error: Forbidden for url: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f9f0-09b9-####### Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/local/lib/python3.11/site-packages/uvicorn/__main__.py", line 4, in <module> uvicorn.main() │ └ <Command main> └ <module 'uvicorn' from '/usr/local/lib/python3.11/site-packages/uvicorn/__init__.py'> File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1485, in __call__ return self.main(*args, **kwargs) │ │ │ └ {} │ │ └ () │ └ <function Command.main at 0x7fe0de99ee80> └ <Command main> File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1406, in main rv = self.invoke(ctx) │ │ └ <click.core.Context object at 0x7fe0df866850> │ └ <function Command.invoke at 0x7fe0de99eb60> └ <Command main> File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1269, in invoke return ctx.invoke(self.callback, **ctx.params) │ │ │ │ │ └ {'host': '0.0.0.0', 'port': 8080, 'forwarded_allow_ips': '*', 'workers': 1, 'app': 'open_webui.main:app', 'uds': None, 'fd': ... │ │ │ │ └ <click.core.Context object at 0x7fe0df866850> │ │ │ └ <function main at 0x7fe0de658b80> │ │ └ <Command main> │ └ <function Context.invoke at 0x7fe0de99dda0> └ <click.core.Context object at 0x7fe0df866850> File "/usr/local/lib/python3.11/site-packages/click/core.py", line 824, in invoke return callback(*args, **kwargs) │ │ └ {'host': '0.0.0.0', 'port': 8080, 'forwarded_allow_ips': '*', 'workers': 1, 'app': 'open_webui.main:app', 'uds': None, 'fd': ... │ └ () └ <function main at 0x7fe0de658b80> File "/usr/local/lib/python3.11/site-packages/uvicorn/main.py", line 424, in main run( └ <function run at 0x7fe0de8f94e0> File "/usr/local/lib/python3.11/site-packages/uvicorn/main.py", line 594, in run server.run() │ └ <function Server.run at 0x7fe0de8f8d60> └ <uvicorn.server.Server object at 0x7fe0dea7ad50> File "/usr/local/lib/python3.11/site-packages/uvicorn/server.py", line 67, in run return asyncio_run(self.serve(sockets=sockets), loop_factory=self.config.get_loop_factory()) │ │ │ │ │ │ └ <function Config.get_loop_factory at 0x7fe0dea814e0> │ │ │ │ │ └ <uvicorn.config.Config object at 0x7fe0de666b50> │ │ │ │ └ <uvicorn.server.Server object at 0x7fe0dea7ad50> │ │ │ └ None │ │ └ <function Server.serve at 0x7fe0de8f8e00> │ └ <uvicorn.server.Server object at 0x7fe0dea7ad50> └ <function asyncio_run at 0x7fe0de991e40> File "/usr/local/lib/python3.11/site-packages/uvicorn/_compat.py", line 30, in asyncio_run return runner.run(main) │ │ └ <coroutine object Server.serve at 0x7fe0de6558a0> │ └ <function Runner.run at 0x7fe0dec40fe0> └ <asyncio.runners.Runner object at 0x7fe0de8aed90> File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) │ │ │ └ <Task pending name='Task-1' coro=<Server.serve() running at /usr/local/lib/python3.11/site-packages/uvicorn/server.py:71> wai... │ │ └ <cyfunction Loop.run_until_complete at 0x7fe0de6cc040> │ └ <uvloop.Loop running=True closed=False debug=False> └ <asyncio.runners.Runner object at 0x7fe0de8aed90> File "/app/backend/open_webui/main.py", line 1710, in process_chat form_data, metadata, events = await process_chat_payload( │ │ └ <function process_chat_payload at 0x7fe061df7d80> │ └ {'user_id': '290239f3-e91c-4e8e-9dbc-dd503bb9a0d8', 'chat_id': 'dd1c9f9c-abdb-4b4b-b772-615d6ec91f85', 'message_id': 'a9f8e32... └ {'stream': True, 'model': 'qwen3-max-2026-01-23', 'messages': [{'role': 'user', 'content': '生成一个素描画,一只可爱的猫咪坐在窗台上,窗外是星空,数字艺术风格... File "/app/backend/open_webui/utils/middleware.py", line 1588, in process_chat_payload form_data = await chat_image_generation_handler( └ <function chat_image_generation_handler at 0x7fe061df7b00> File "/app/backend/open_webui/utils/middleware.py", line 1130, in chat_image_generation_handler images = await image_generations( └ <function image_generations at 0x7fe063f4e5c0> File "/app/backend/open_webui/routers/images.py", line 639, in image_generations image_data, content_type = get_image_data(image_url, headers) │ │ └ {'Authorization': 'Bearer sk-gtL0gS#############ZwuDYhI3SwmrD', 'Content-Type': 'application/json'} │ └ 'https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f9f0-09b9-4dc7-8485-476514867d02.png?Ex... └ <function get_image_data at 0x7fe063f4e020> > File "/app/backend/open_webui/routers/images.py", line 482, in get_image_data r.raise_for_status() │ └ <function Response.raise_for_status at 0x7fe0dc32c5e0> └ <Response [403]> File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1026, in raise_for_status raise HTTPError(http_error_msg, response=self) │ │ └ <Response [403]> │ └ '403 Client Error: Forbidden for url: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f9... └ <class 'requests.exceptions.HTTPError'> requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/8d/20260211/7147d395/6ff1f###14867d02.png?### ``` ### Additional Information This is my custom API's response ```json { "data": [ { "url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/7a/2####################################", "b64_json": "", "revised_prompt": "" } ], "created": 1770802551, "metadata": { "output": { "choices": [ { "finish_reason": "stop", "message": { "content": [ { "image": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/7a/2####################################", "type": "image" } ], "role": "assistant" } } ], "finished": true }, "usage": { "image_count": 1, "input_tokens": 0, "output_tokens": 0, "size": "1024*1024", "total_tokens": 0 }, "request_id": "65555544-5157-4765-9e1d-0d06a9c550cf" } } ```
GiteaMirror added the bug label 2026-04-25 09:08:53 -05:00
Author
Owner

@tjbck commented on GitHub (Feb 23, 2026):

Should be addressed.

<!-- gh-comment-id:3942047323 --> @tjbck commented on GitHub (Feb 23, 2026): Should be addressed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#34965