mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[GH-ISSUE #16395] issue: max_tokens deprecated, breaking Title Generation with GPT-5 #33416
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 @17jmumford on GitHub (Aug 8, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/16395
Check Existing Issues
Installation Method
Pip Install for locally, docker in production
Open WebUI Version
latest
Ollama Version (if applicable)
No response
Operating System
mac
Browser (if applicable)
chrome
Confirmation
README.md.Expected Behavior
When a title is generated in the background for a chat, it sets the max_tokens parameter to ensure the title fits in the sidebar. Normally, this generation works great.
Actual Behavior
max_tokens was marked as deprecated on the OpenAI API for /chat/completions. Interestingly, despite stating it wouldn't work with o-series models, these models are successfully generating titles. Does Open WebUI have a hardcoded fix for this already, or is the documentation wrong?
However, the music finally stopped with GPT-5. Title generation will error out with these models. See screenshots and links below.
Now, obviously you can set a different model to generate the title in Open WebUI. Unfortunately, Open WebUI requires a public base model to be set as the task model. Our organization is set up where the only public models are models created inside of Open WebUI. We humbly request that Open WebUI either updates title generation to use max_completion_tokens for title generation length limiting, or allow Open WebUI models to be selected as task models.
Steps to Reproduce
Pretty easy to reproduce. Just use a GPT-5 model 🤷♂️
Logs & Screenshots
Here is the error message that our proxy gateway (similar to LiteLLM but homegrown) caught:
openai.badrequesterror: Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}
Additional Information
Here is the link to the documentation on OpenAI. Again, despite saying that o-series models can't use this parameter, they actually generate titles successfully 🤷 . Not sure if Open WebUI has a hardcoded fix for this, or if the documentation is wrong.
https://platform.openai.com/docs/api-reference/chat/create
@17jmumford commented on GitHub (Aug 8, 2025):
After grepping the codebase, there IS a hardcoded fix for this with o-series models.
https://github.com/open-webui/open-webui/blob/main/backend/open_webui/routers/openai.py
So it seems like the short-term fix would be to add gpt-5 to the list 🤷
Longterm, this is not ideal. However, I understand that other proxy systems emulating OpenAI will be expecting the deprecated max_tokens parameter to be the default. Anthropic, Bedrock, Google, Grok, all accept max_tokens with their OpenAI emulators. I suspect at least one of them would break if we switched to max_completion_tokens.
I wonder if there is some way to identify reasoning models automatically....?
I'll make a PR to get this updated.
@17jmumford commented on GitHub (Aug 8, 2025):
https://github.com/open-webui/open-webui/pull/16397
Merged!
@diegoscl commented on GitHub (Feb 4, 2026):
This issue still pops up when you're using a gateway like OpenRouter or Cloudflare AI Gateway.
From what I can tell, it happens because GPT-5 models aren't being recognized as "reasoning models" in this context. The logic at line 767 doesn't trigger the switch from
max_tokenstomax_completion_tokensbecause it's specifically looking for model IDs that start with "o1", "o3", "o4", or "gpt-5". Since gateways usually format IDs as{provider}/{model}, an ID likeopenai/gpt-5-nanoends up breaking the check.@17jmumford, What do you think of this?
@danny70437 commented on GitHub (Feb 4, 2026):
also in gpt-5-mini - we use lm-proxy to connect to openai.com; opeonwebui connects to 127.0.0.1:8000 - so, the URL-Check does not work. openwebui sends to wrong parameter max_token instead of max_completion_tokens.