-
-
Notifications
You must be signed in to change notification settings - Fork 909
fix: update OpenAI API to use max_completion_tokens instead of max_tokens #2000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update OpenAI API to use max_completion_tokens instead of max_tokens #2000
Conversation
…kens The OpenAI API has deprecated max_tokens in favor of max_completion_tokens for newer models. This change updates both text and image model calls.
WalkthroughReplaced use of Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Inference as inference.ts
participant OpenAI
Client->>Inference: request inferFromText / inferFromImage
Note right of Inference #DDEBF7: Read serverConfig.inference\n(useMaxCompletionTokens, maxOutputTokens)
alt useMaxCompletionTokens == true
Inference->>OpenAI: send completion with\n`max_completion_tokens = maxOutputTokens`
else useMaxCompletionTokens == false
Inference->>OpenAI: send completion with\n`max_tokens = maxOutputTokens`
end
OpenAI-->>Inference: completion response
Inference-->>Client: return response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (3)docs/docs/03-configuration.md📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/shared/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/shared/inference.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use oxlint as the linter for JavaScript/TypeScript code
Files:
packages/shared/inference.ts
packages/shared/**
📄 CodeRabbit inference engine (AGENTS.md)
Shared code and types reside in packages/shared
Files:
packages/shared/inference.ts
🔇 Additional comments (1)
packages/shared/inference.ts (1)
130-130: Consistent parameter update for image inference.The change mirrors the update in
inferFromText(line 93), ensuring consistency across both text and image inference methods.
|
Can this be looked at and hopefully merged? It would be really nice to get this merged so I can use gpt-5-mini for summarization instead of being stuck on gpt-4.1-mini, especially since gpt-5-mini is only a bit over half the price for input tokens. |
|
Is there anything blocking this fix? I updated my instance to use gpt-5-nano after adding more API credits, and I'd prefer to leave it on gpt-5-nano, but I really like the AI summarization and tagging features. |
|
hey folks, sorry for taking too long to get back to this. Biggest concern with this PR is what it'll break. People use the openai client for almost all other providers, and I don't know which providers wouldn't support this. So here's my suggestion. Can we add a new env variable that controls which field to pass, and default it as the old behavior for now, and then in the next release we switch the default after giving people a headsup in the release notes? |
|
This makes sense to me. Might be best to just leave a |
|
@MohamedBassem Took a crack at an update - decided to go with a variable that controls the field to pass vs having 2 token fields for now as that seemed a bit clearer to me, and less risk of someone setting both or similar and having to explain what happens in those cases. |
|
Thanks a lot @BenjaminMichaelis, and sorry once more for the delay :) This will be in the nightly image in around 30mins. |
|
When should we look for this in the regular release? I've added the |
|
Should be in the next release |
The OpenAI API has deprecated max_tokens in favor of max_completion_tokens for newer models. This change updates both text and image model calls.
Fixes: #1969
API Spec: https://platform.openai.com/docs/api-reference/chat/create