Repository navigation
Description
Problem
ChatGPTBox's OpenAI-compatible Chat Completions client always sends a token limit, but there is no setting to select the request field name (max_tokens versus max_completion_tokens).
This breaks custom API endpoints and models that only accept max_completion_tokens, even when the model is configured under OpenAI (API) with a custom API URL. The Max Response Token Length slider only changes the value, not the field name.
Example error:
{
"error": {
"message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.",
"type": "invalid_request_error",
"param": "max_tokens",
"code": "unsupported_parameter"
}
}Why the current automatic handling misses valid configurations
src/services/apis/openai-token-params.mjsuses a provider + model-name regex to selectmax_completion_tokens. Unrecognized model IDs (for example,o3) fall back tomax_tokens, even on the built-in OpenAI provider.- For custom providers,
provider !== 'openai'so a model ID such asgpt-5.2also falls back tomax_tokens, regardless of what the upstream API accepts. - Using Advanced → API Url → Custom OpenAI API Url does not solve requests that use a model name outside the built-in regex.
- Updating model-name recognition alone cannot cover proxies, custom aliases, and future models.
The issue is visible in the v2.7.1 release and the current source as of 2026-11-01. Reported with Firefox and a configured OpenAI-compatible endpoint (the user's exact provider/model ID is not available for this report).
Desired behavior
Add a setting under Advanced → API Params, for OpenAI-compatible Chat Completions requests:
- Auto (default): preserve the existing provider/model detection.
- max_tokens: explicitly send the legacy field.
- max_completion_tokens: explicitly send the newer field.
Keep the current token-count slider and existing /v1/completions handling unchanged. The chosen field should not be duplicated by extra request-body parameters.
This allows people to use OpenAI-compatible proxies and nonstandard model IDs without modifying or rebuilding the extension.
Related
- Please add an option that lets us use "max_completion_tokens" instead of "max_tokens" #908 (closed): initial GPT-5/5.1 parameter support; automatic handling was improved, but there is still no manual override.
- Support OpenAI reasoning models via OpenAI API #792 (open): broader reasoning-model support.
Would a small backward-compatible, opt-in override be welcome?
Activity
pullfrog commentedon Oct 31, 2026