Skip to content

Support GPT-5.x reasoning models in OpenAI provider (max_completion_tokens, no custom temperature) - #227

Open
surgaev wants to merge 1 commit into
pickle-com:mainfrom
surgaev:fix/gpt5-temperature-max-completion-tokens
Open

Support GPT-5.x reasoning models in OpenAI provider (max_completion_tokens, no custom temperature)#227
surgaev wants to merge 1 commit into
pickle-com:mainfrom
surgaev:fix/gpt5-temperature-max-completion-tokens

Conversation

@surgaev

@surgaev surgaev commented Aug 9, 2026

Copy link
Copy Markdown

What

src/features/common/ai/providers/openai.js calls the Chat Completions API with max_tokens and a custom temperature on all three call sites (createLLM's direct + Portkey paths, and createStreamingLLM).

GPT-5.x reasoning models reject these params:

  • max_tokens is deprecated in favor of max_completion_tokens and is rejected outright by reasoning models.
  • Reasoning models only support the default 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

  • Replaced max_tokens with max_completion_tokens in all three call sites.
  • Removed the temperature param 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-5 and gpt-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 since max_completion_tokens is accepted by both model families.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant