Skip to content

Allow choosing max_tokens or max_completion_tokens for OpenAI-compatible requests #1133

Open

Description

@crema-lida

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.mjs uses a provider + model-name regex to select max_completion_tokens. Unrecognized model IDs (for example, o3) fall back to max_tokens, even on the built-in OpenAI provider.
  • For custom providers, provider !== 'openai' so a model ID such as gpt-5.2 also falls back to max_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

Would a small backward-compatible, opt-in override be welcome?

Activity

  1. pullfrog commented on Oct 31, 2026

    @pullfrog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions