Support GPT-5.x reasoning models in OpenAI provider (max_completion_tokens, no custom temperature) - #227
Open
surgaev wants to merge 1 commit into
Conversation
Newer reasoning models (o1/o3/gpt-5.x and later) reject two things this provider was sending unconditionally: 1. A custom `temperature` value - these models only support the default (1), and requests with any other value now fail with "Unsupported value: 'temperature' does not support X with this model. Only the default (1) value is supported." 2. `max_tokens` - deprecated in favor of `max_completion_tokens` for these models; requests fail with "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead." This switches all three OpenAI chat-completion call sites (plain createLLM, the Portkey proxy path, and createStreamingLLM) to use max_completion_tokens and stop sending an explicit temperature, letting the API use each model's own default. Older non-reasoning models accept max_completion_tokens as well, so this doesn't need to special-case by model.
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.
What
src/features/common/ai/providers/openai.jscalls the Chat Completions API withmax_tokensand a customtemperatureon all three call sites (createLLM's direct + Portkey paths, andcreateStreamingLLM).GPT-5.x reasoning models reject these params:
max_tokensis deprecated in favor ofmax_completion_tokensand is rejected outright by reasoning models.temperature(1); passing any other value returns a 400 error.Any user selecting a GPT-5.x model (
gpt-5,gpt-5-mini,gpt-5.x-*, etc.) as their LLM provider gets a hard API error instead of a response.Fix
max_tokenswithmax_completion_tokensin all three call sites.temperatureparam from the request bodies so reasoning models use their required default.This only changes the request payload shape; it doesn't change any public function signatures, so it's a drop-in fix.
Testing
Verified locally against
gpt-5andgpt-5-mini: requests that previously failed with a 400 (Unsupported parameter: 'temperature'/'max_tokens' is not supported with this model) now succeed, and existing non-reasoning models (gpt-4.1,gpt-4o) continue to work unaffected sincemax_completion_tokensis accepted by both model families.