fix(openai): strip reasoning param and map to reasoning_effort for "/v1/chat/completions"#1374
Open
Jinhyeok33 wants to merge 1 commit into
Open
fix(openai): strip reasoning param and map to reasoning_effort for "/v1/chat/completions"#1374Jinhyeok33 wants to merge 1 commit into
Jinhyeok33 wants to merge 1 commit into
Conversation
OpenAI's /v1/chat/completions rejects the unknown `reasoning` parameter that AnthropicTransformer + ReasoningTransformer leave on the request, causing "Unknown parameter: 'reasoning'" (400) whenever Claude Code sends a thinking-enabled request to an OpenAI provider. Add transformRequestIn to OpenAITransformer that maps reasoning.effort to OpenAI's native reasoning_effort and strips reasoning / thinking / enable_thinking. Mirrors the pattern already used by CerebrasTransformer. Closes musistudio#652 Related to musistudio#510, musistudio#668
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenAI's
/v1/chat/completionsrejects the unknown parameterreasoning, returning a 400:Unknown parameter: 'reasoning'
This breaks every provider whose
transformer.useincludesOpenAIwhenever Claude Code sends a thinking-enabled request(Plan Mode, think harder, etc.).
Closes #652
Related to #510, #668
Fix
Add
transformRequestIntoOpenAITransformerthat:reasoning.effort→ OpenAI's nativereasoning_effort(the field actually accepted by o1/o3/o4/gpt-5 on/v1/chat/completions) when an effort level is set and not"none".reasoning,thinking, andenable_thinkingso OpenAI's strict-parameter validation passes.The
ThinkLevelvalues produced by this codebase —none | low | medium | high(seepackages/core/src/utils/thinking.ts) — are exactly the values OpenAI accepts forreasoning_effort, so the mapping is a 1:1 passthrough with no value-spaceconversion needed.
Verification
Unknown parameter: 'reasoning'400 against an OpenAI provider with Plan Mode enabled (before this change).reasoning_effort(when an effort is set) andno longer contains
reasoning/thinking/enable_thinking.