Skip to content

BadRequestError: 'max_tokens' parameter deprecated - should use 'max_completion_tokens' #63

@ryota-murakami

Description

@ryota-murakami

Bug Report

Environment

  • Package version: 0.10.0
  • Node version: 22.18.0 (via Volta)
  • Error location: openai/core/error.mjs:41

Error Message

file:///Users/ryotamurakami/.volta/tools/image/packages/@laststance/git-gpt-commit/lib/node_modules/@laststance/git-gpt-commit/node_modules/openai/core/error.mjs:41
            return new BadRequestError(status, error, message, headers);
                   ^

BadRequestError: 400 Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.

Description

OpenAI has deprecated the max_tokens parameter in newer API versions and models (particularly the o1 series). The parameter has been renamed to max_completion_tokens.

Suggested Fix

Replace all instances of max_tokens with max_completion_tokens in the OpenAI API calls.

Temporary Workaround

Users experiencing this issue can:

  1. Use an older model that still supports max_tokens
  2. Downgrade to an older version of the package
  3. Wait for the fix to be released

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions