Anthropic/ChatCompletions clients → ChatGPT Codex via Responses API - #1
Anthropic/ChatCompletions clients → ChatGPT Codex via Responses API#1Jiliac wants to merge 10 commits into
Conversation
…ing, stream reasoning-summary events, RedactedThinking
…ch, and buffer [DONE]/block-close handling
…for Codex Responses upstream
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…s, permissive tool_choice, unknown input-item passthrough
|
Closing as superseded for our local deployment by a chained architecture: Claude Code → Plano routing → CLIProxyAPI → Codex. The direct Anthropic/ChatCompletions → Codex Responses bridge remains incomplete for client-nonstream/upstream-stream and tool/subagent flows, so the PR’s current end-to-end compatibility claim is too broad. Preserving the branch for reference and possible extraction of independently useful fixes. |
Stacked on katanemo#988 (adil/fix-responses-identity-passthrough) — merge that first; this PR's diff will shrink to just the commits below once it lands.
Problem
Claude Code speaks the Anthropic Messages API. The ChatGPT Codex backend only serves
/backend-api/codex/responses(the Responses API) — any client hitting it with a/chat/completions-shaped or Messages-shaped payload gets a hard 404 before this PR. There were two independent root causes:providers/id.rs, so it never got routed to the Responses API in the first place./chat/completionsdefault inclients/endpoints.rsinstead of/responses.What was added
MessagesRequest ⇄ ResponsesAPIRequestandChatCompletionsRequest → ResponsesAPIRequesttransforms, including mapping reasoning into Anthropicthinkingblocks with multi-turnencrypted_contentreplay.[DONE]synthesis for the ChatCompletions leg.InputItemuntagged-enum fix: replaced with a manual type-dispatchingDeserializeimpl. This fixes a bug whereItemReferencewas silently swallowingfunction_call/reasoningitems — it also benefits the pre-existing identity passthrough path, not just this feature.max_output_tokens,truncation,metadata,user,temperature,top_p), migrate the nestedreasoningobject handling, and add theReasoningEffort::None/Minimalvariants Codex can return.common/llm_providers.rs: an explicitopenai/prefix no longer loses to another provider's wildcard alias. This was a pre-existing bug, exposed by the new gpt-5.6 registry entries added under thechatgptprovider.Verification
cargo fmt,cargo clippy -D warnings, and the wasm build target all green.gpt-5.6-luna,gpt-5.6-sol,gpt-5.6-terra, andgpt-5.4.[DONE], correctfinish_reason).openai/*explicit prefix beatschatgpt/*wildcard).Relationship to katanemo#958
This is orthogonal to katanemo#958. It deliberately does not adopt that PR's JSON post-pass adapter approach — all Codex-specific quirks here live on the typed
ResponsesAPIRequestinsidenormalize_for_upstream, not as a generic JSON patch layer. Conflict surface should be minimal:provider_models.yamlis untouched by this PR.Known follow-ups (minor, listed for transparency)
message_startemitsmodel: "unknown"for Codex streams.incomplete → Lengthstop-reason mapping on the ChatCompletions leg is broader than strictly specced.signature_delta). Claude Code accepts this shape fine, but a non-empty reasoning summary has not been exercised end-to-end.🤖 Generated with Claude Code