I have searched the existing issues and discussions.
I am using the latest version of Open WebUI.
Installation Method
Pip Install
Open WebUI Version
v0.5.20
Ollama Version (if applicable)
No response
Operating System
Windows 10
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
Hello, thank you for taking the time to read this.
I am currently using the 4o model through the OpenAI API. Previously, options like "max tokens" were not functioning at all, so I modified the apps/openai/main.py file to forcefully limit tokens as shown below.
However, after the update, it seems to bypass this modification and operates without the limit. As a result, my API costs have skyrocketed.
I assume there is something I am missing.
Could you please let me know how to properly set token limits when using the OpenAI API?
Thank you very much!
Actual Behavior
.
Steps to Reproduce
.
Logs & Screenshots
Originally created by @luna8484 on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12375
### 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
v0.5.20
### Ollama Version (if applicable)
_No response_
### Operating System
Windows 10
### 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
Hello, thank you for taking the time to read this.
I am currently using the 4o model through the OpenAI API. Previously, options like "max tokens" were not functioning at all, so I modified the apps/openai/main.py file to forcefully limit tokens as shown below.
However, after the update, it seems to bypass this modification and operates without the limit. As a result, my API costs have skyrocketed.
I assume there is something I am missing.
Could you please let me know how to properly set token limits when using the OpenAI API?
Thank you very much!
### Actual Behavior
.
### Steps to Reproduce
.
### Logs & Screenshots



GiteaMirror
added the bug label 2026-05-20 21:19:55 -05:00
max_token is definitely being forwarded with the latest version.
<!-- gh-comment-id:2774152532 -->
@tjbck commented on GitHub (Apr 3, 2025):

<img width="1700" alt="Image" src="https://github.com/user-attachments/assets/4f2d8f09-48ed-40a5-8502-53bf07de71d3" />
max_token is definitely being forwarded with the latest version.
I can't seem to make it work. Could you give me some advice, please?
<!-- gh-comment-id:2774470376 -->
@luna8484 commented on GitHub (Apr 3, 2025):
I can't seem to make it work. Could you give me some advice, please?

Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @luna8484 on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12375
Check Existing Issues
Installation Method
Pip Install
Open WebUI Version
v0.5.20
Ollama Version (if applicable)
No response
Operating System
Windows 10
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
Hello, thank you for taking the time to read this.
I am currently using the 4o model through the OpenAI API. Previously, options like "max tokens" were not functioning at all, so I modified the apps/openai/main.py file to forcefully limit tokens as shown below.
However, after the update, it seems to bypass this modification and operates without the limit. As a result, my API costs have skyrocketed.
I assume there is something I am missing.
Could you please let me know how to properly set token limits when using the OpenAI API?
Thank you very much!
Actual Behavior
.
Steps to Reproduce
.
Logs & Screenshots
@luna8484 commented on GitHub (Apr 3, 2025):
@tjbck commented on GitHub (Apr 3, 2025):
max_token is definitely being forwarded with the latest version.
@luna8484 commented on GitHub (Apr 3, 2025):
@luna8484 commented on GitHub (Apr 3, 2025):
I can't seem to make it work. Could you give me some advice, please?