fix: use max_completion_tokens for gpt-5/o-series models - #6
Open
mogliabr wants to merge 1 commit into
Open
Conversation
The Chat Completions API rejects max_tokens on reasoning models (gpt-5 and the o-series) and requires max_completion_tokens instead. buildPayload() now selects the token-limit field based on the model family prefix, so future gpt-5.x releases are covered without further changes. Adds coverage for gpt-5.6-luna and o3-mini.
mogliabr
force-pushed
the
fix/max-completion-tokens
branch
from
August 18, 2026 16:14
3ded037 to
46911a0
Compare
Author
|
I get this bug using lib my personal fix can be affected by furure updates so i sended the path. Thanks for created it. Fist time using github im only subversion and cvs user for commit. Get learn how use git hub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Chat Completions API rejects
max_tokenson reasoning models —gpt-5and theo-series — returning400 Unsupported parameter: 'max_tokens'. These models requiremax_completion_tokensinstead.buildPayload()currently always sendsmax_tokenswhenmaxTokensis set:Fix
Select the token-limit field based on the model family prefix:
tokenLimitKey()returnsmax_completion_tokensforgpt-5,o1,o3,o4(matched by prefix, so futuregpt-5.xreleases are covered without changes) andmax_tokensfor everything else.Tests
Added coverage for
gpt-5.6-lunaando3-miniassertingmax_completion_tokensis emitted andmax_tokensis absent. The existinggpt-4-turbotest still assertsmax_tokens, confirming classic chat models are unaffected.composer lintandcomposer test(71 passed) pass locally.