Max Tokens do not work at all for Openrouter #9686
Unanswered
jfangzr
asked this question in
Troubleshooting
Replies: 2 comments 2 replies
|
First off, if the system correctly fetches the max context values from OpenRouter, it will have the expected amount without needing to set anything in the UI. You should check your error logs if the system is having trouble fetching the official model list from OR, which includes context window values: 2025-09-18T12:26:32.264Z debug: [BaseClient] Context Count (1/2)
{
remainingContextTokens: 235921,
maxContextTokens: 235930,
}
2025-09-18T12:26:32.264Z debug: [BaseClient] Context Count (2/2)
{
remainingContextTokens: 235921,
maxContextTokens: 235930,
}
2025-09-18T12:26:32.264Z debug: [BaseClient] tokenCountMap:
{
83b5591e-ea6d-431a-9078-e91311aef796: 6,
}
2025-09-18T12:26:32.264Z debug: [BaseClient]
{
promptTokens: 9,
remainingContextTokens: 235921,
payloadSize: 1,
maxContextTokens: 235930,
}
2025-09-18T12:26:32.264Z debug: [api/server/controllers/agents/client.js #useMemory] User 682f49b90f07376815c38ef2 does not have USE permission for memories
2025-09-18T12:26:32.264Z debug: [BaseClient] tokenCountMap
{
83b5591e-ea6d-431a-9078-e91311aef796: 6,
}
2025-09-18T12:26:32.264Z debug: [BaseClient] userMessage
{
messageId: "83b5591e-ea6d-431a-9078-e91311aef796",
parentMessageId: "00000000-0000-0000-0000-000000000000",
conversationId: "4587b6f4-42bd-4eb9-8cd7-db2fba0eb94e",
sender: "User",
text: "hi there",
isCreatedByUser: true,
tokenCount: 6,
}
2025-09-18T12:26:32.281Z debug: [Balance.check] Initial state
{
user: "some-user-id",
model: "qwen/qwen3-235b-a22b-thinking-2507",
endpoint: "OpenRouter",
valueKey: undefined,
tokenType: "prompt",
amount: 9,
balance: 24953073.24000012,
multiplier: 6,
endpointTokenConfig: false,
}
I don't know where you set this parameter, but After setting this 2025-09-18T12:30:51.919Z debug: [BaseClient] Context Count (1/2)
{
remainingContextTokens: 29551,
maxContextTokens: 29800,
}
2025-09-18T12:30:51.920Z debug: [BaseClient] Context Count (2/2)
{
remainingContextTokens: 29551,
maxContextTokens: 29800,
}
2025-09-18T12:30:51.920Z debug: [BaseClient] tokenCountMap:
{
83b5591e-ea6d-431a-9078-e91311aef796: 11,
bd9ed3ee-cdc3-49c4-ad2d-64255f2d1872: 229,
688e4d6c-98b1-471c-b668-a905b5491ec3: 6,
}
2025-09-18T12:30:51.920Z debug: [BaseClient]
{
promptTokens: 249,
remainingContextTokens: 29551,
payloadSize: 3,
maxContextTokens: 29800,
}29,800 is roughly ~90% of 33,111, as we will conservatively always use 90% of the configured/system context window. |
0 replies
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment






Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What happened?
I expected that the entire context window would be given to me, but apparently not at all. It seems like the window is cutoff at 2048 or 4096 tokens. I was using qwen/qwen3-235b-a22b-thinking-2507 via OpenRouter, and I specifically set the max_tokens parameter to 131072. Well, it did not work. I also tried in the UI to set the preset to 100000 for both max context tokens and max tokens, but this is still not working. The output is still truncated after just a few thousand tokens at most. I am following the instructions exactly, to the point, so I don't know what is going wrong at all. I don't know why on earth there is token number cutoff, I thought librechat did not impose any output token limits itself?
also, I realized I used the wrong github account to create the previous issue, I am going to close the previous issue #9682
Version Information
$ docker images | grep librechat
ghcr.io/danny-avila/librechat-dev latest d7aeafdec1ac 5 days ago 1.57GB
ghcr.io/danny-avila/librechat-rag-api-dev-lite latest d813432c9b0a 3 weeks ago 1.68GB
Steps to Reproduce
What browsers are you seeing the problem on?
No response
Relevant log output
Screenshots
No response
Code of Conduct
All reactions