[GH-ISSUE #7125] openai: support max_completion_tokens due to deprecation of max_tokens #51037

Open
opened 2026-04-28 17:58:03 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @codefromthecrypt on GitHub (Oct 8, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7125

max_tokens is now deprecated for max_completion_tokens. I suspect we should support both. One way is to define another field in our request object and then default if one or the other isn't set defbf9425a/openai/openai.go (L77)

See https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens
See 10053bef25/openapi.yaml (L9854-L9866)

Originally created by @codefromthecrypt on GitHub (Oct 8, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7125 max_tokens is now deprecated for max_completion_tokens. I suspect we should support both. One way is to define another field in our request object and then default if one or the other isn't set https://github.com/ollama/ollama/blob/defbf9425af8228f3420d567e9eeaa29d8ac87e3/openai/openai.go#L77 See https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens See https://github.com/openai/openai-openapi/blob/10053bef25cd50a7424f5265ba51a7a63ba95b48/openapi.yaml#L9854-L9866
GiteaMirror added the feature requestapi labels 2026-04-28 17:58:06 -05:00
Author
Owner

@starpit commented on GitHub (Aug 19, 2025):

Could we add a MaxCompletionsToken field, and mark the existing MaxTokens as deprecated?

Fwiw, vLLM accepts both max_tokens and max_completion_tokens without complaint. Gemini's OpenAI compatibility endpoint refuses to accept both, responding with "max_tokens and max_completion_tokens cannot both be set". Oof.

<!-- gh-comment-id:3201413923 --> @starpit commented on GitHub (Aug 19, 2025): Could we add a MaxCompletionsToken field, and mark the existing MaxTokens as deprecated? Fwiw, vLLM accepts both `max_tokens` and `max_completion_tokens` without complaint. Gemini's OpenAI compatibility endpoint refuses to accept both, responding with "max_tokens and max_completion_tokens cannot both be set". Oof.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#51037