Skip to content

[chatgpt] Use max_completion_tokens for OpenAI requests - #21459

Merged
lsiepel merged 1 commit into
openhab:mainfrom
kaikreuzer:chatgpt-max-completion-tokens
Aug 23, 2026
Merged

[chatgpt] Use max_completion_tokens for OpenAI requests#21459
lsiepel merged 1 commit into
openhab:mainfrom
kaikreuzer:chatgpt-max-completion-tokens

Conversation

@kaikreuzer

Copy link
Copy Markdown
Member

Trying to use more recent (specifically reasoning) models from OpenAI, I get this error in my log:

Error response payload from [https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions) (POST): { "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" } }

max_tokens parameter is deprecated and not even allowed anymore for reasoning models. Instead, max_completion_tokens should be used.

This PR is keeping the existing maxTokens configuration key for backward compatibility while sending OpenAI-compatible chat completion payloads with max_completion_tokens.

Keep the existing maxTokens configuration key for backward compatibility while sending OpenAI-compatible chat completion payloads with max_completion_tokens.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Kai Kreuzer <kai@openhab.org>
@kaikreuzer
kaikreuzer requested a review from florian-h05 August 22, 2026 22:09
@kaikreuzer kaikreuzer added the bug An unexpected problem or unintended behavior of an add-on label Aug 22, 2026

@lsiepel lsiepel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks LGTM

@lsiepel
lsiepel merged commit 4a30002 into openhab:main Aug 23, 2026
3 checks passed
@lsiepel lsiepel added this to the 5.3 milestone Aug 23, 2026
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Aug 28, 2026
Keep the existing maxTokens configuration key for backward compatibility while sending OpenAI-compatible chat completion payloads with max_completion_tokens.

Signed-off-by: Kai Kreuzer <kai@openhab.org>
@lolodomo

Copy link
Copy Markdown
Contributor

What about backporting that fix to 5.2.x branch ?

@florian-h05

Copy link
Copy Markdown
Contributor

If possible (no merge conflicts), would be good to

lolodomo pushed a commit that referenced this pull request Aug 29, 2026
Keep the existing maxTokens configuration key for backward compatibility while sending OpenAI-compatible chat completion payloads with max_completion_tokens.

Signed-off-by: Kai Kreuzer <kai@openhab.org>
@lolodomo lolodomo added the backported A PR that has been cherry-picked to a patch release branch label Aug 29, 2026
@lolodomo

Copy link
Copy Markdown
Contributor

Backported to branch 5.2.x

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

Labels

backported A PR that has been cherry-picked to a patch release branch bug An unexpected problem or unintended behavior of an add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants