[GH-ISSUE #12375] issue: OpenAI API token limit not working #119885

Closed
opened 2026-05-20 21:19:54 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @luna8484 on GitHub (Apr 3, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12375

Check Existing Issues

  • 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

Image
Image
Image

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 ![Image](https://github.com/user-attachments/assets/614c3a21-8c6b-4bb6-93d5-101ae4722deb) ![Image](https://github.com/user-attachments/assets/762fa797-e5bf-4e24-9ae3-a614212a34b4) ![Image](https://github.com/user-attachments/assets/b0a319c9-326d-4ec4-95b4-8895ebc88bef)
GiteaMirror added the bug label 2026-05-20 21:19:55 -05:00
Author
Owner

@luna8484 commented on GitHub (Apr 3, 2025):

Image

<!-- gh-comment-id:2774120436 --> @luna8484 commented on GitHub (Apr 3, 2025): ![Image](https://github.com/user-attachments/assets/b6d79362-0eb1-421b-9060-29a81ffbde11)
Author
Owner

@tjbck commented on GitHub (Apr 3, 2025):

Image

Image

max_token is definitely being forwarded with the latest version.

<!-- gh-comment-id:2774152532 --> @tjbck commented on GitHub (Apr 3, 2025): ![Image](https://github.com/user-attachments/assets/daa3b1c3-0422-40cf-bcba-33eea4fa9382) <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.
Author
Owner

@luna8484 commented on GitHub (Apr 3, 2025):

Image

<!-- gh-comment-id:2774468708 --> @luna8484 commented on GitHub (Apr 3, 2025): ![Image](https://github.com/user-attachments/assets/11c85084-1209-4789-8cdd-3f04e6c7e0e9)
Author
Owner

@luna8484 commented on GitHub (Apr 3, 2025):

I can't seem to make it work. Could you give me some advice, please?

Image

<!-- 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? ![Image](https://github.com/user-attachments/assets/65180289-9bd2-4320-b7fc-82bdcc7c42c2)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#119885