Skip to content

fix: use correct token param for newer OpenAI models#435

Merged
gabrielste1n merged 4 commits intoOpenWhispr:mainfrom
alumpe:alumpe/fix-max-token-parameter
Mar 15, 2026
Merged

fix: use correct token param for newer OpenAI models#435
gabrielste1n merged 4 commits intoOpenWhispr:mainfrom
alumpe:alumpe/fix-max-token-parameter

Conversation

@alumpe
Copy link
Contributor

@alumpe alumpe commented Mar 14, 2026

Fix missing max_completion_tokens parameter for GPT-5 models

When selecting a GPT-5 model (e.g. gpt-5-mini, gpt-5-nano, gpt-5.2) as the reasoning model, the app would send no token limit parameter at all in the API request body. The OpenAI API rejected this, returning:

image

The root cause was that the request body construction had no else branch for models that weren't classified as legacy — so gpt-5* models fell through with no token parameter set.

Changes

  • Extracted a private isOlderOpenAiModel() helper with a clear comment, replacing two duplicated inline conditions
  • Added an explicit else branch that sends max_completion_tokens for non-legacy models (gpt-5* and gpt-4.1*)
  • processWithOpenAI(): now sends max_tokens for legacy models (gpt-4o*, gpt-4-, gpt-3), max_completion_tokens for newer chat completions models, and max_output_tokens for the Responses API endpoint
  • processTextStreaming(): same fix applied to the streaming path

alumpe and others added 3 commits March 14, 2026 22:14
- Add tokenParam and supportsTemperature fields to CloudModelDefinition
  and model registry, replacing fragile string prefix matching
- Add getOpenAiApiConfig() helper with fallback for unregistered models
- Fix temperature regression: gpt-4.1 models now correctly send
  temperature (they support it), gpt-5 models correctly omit it
- Add GPT-5.4 as new flagship model across all 10 locales
- Remove isOlderOpenAiModel() in favor of registry-driven lookup
@gabrielste1n gabrielste1n self-requested a review March 15, 2026 19:56
gpt-4.1 models support temperature on both the Responses API and
Chat Completions endpoints. Move the temperature check outside the
if/else branch so it applies to both API paths.
@gabrielste1n gabrielste1n merged commit d56e446 into OpenWhispr:main Mar 15, 2026
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.

2 participants