Tutorials about connecting CC Switch to Claude Code are everywhere, but configuring Codex in CC Switch — whether via relay or direct connection — is rarely explained clearly. Codex and Claude Code use different protocols, so the setup and pitfalls are different. Copying Claude's configuration often results in 400/404 errors. This article focuses on configuring Codex within CC Switch: explaining why the /v1/responses protocol is key to direct connections, providing complete setup steps, comparing relay vs. direct connection, and finally consolidating everything with TeamoRouter using a single baseUrl.
First, Understand: Codex and Claude Code Use Different Protocols
CC Switch can manage multiple agents from one place, but it must use the correct protocol format for each tool when forwarding requests. Here are the protocol differences between the three main tools:
- Claude Code → Uses the Anthropic Messages API (
/v1/messages); - Codex → Uses the OpenAI Responses API (
/v1/responses); - Other OpenAI-compatible CLIs → Mostly use Chat Completions (
/v1/chat/completions).
Many people copy their Claude provider configuration directly to Codex, resulting in mismatched baseUrls and protocol formats — hence 400 (bad request) or 404 (path not found) errors. The first rule of configuring Codex: choose the right protocol and the right path.
Key Point: /v1/responses Determines Whether Codex Can Connect Directly
Newer versions of Codex use the Responses API (/v1/responses) by default — this is the core endpoint for tool calling and reasoning capabilities. Whether a provider supports direct connection for Codex comes down to whether it natively supports /v1/responses passthrough:
- Gateways that support
/v1/responses: Codex can point its baseUrl directly at them, with full support for tool calling, streaming, and reasoning features — this is "direct connection." - Relays that only support
/v1/chat/completions: These require a protocol conversion layer (responses → chat completions) in the middle, which can cause some advanced features to break or behave inconsistently, compromising stability — this is the common compromise of "relay."
So when choosing a Codex provider, make sure it natively supports the Responses protocol. Without it, you'll either have to downgrade to an older protocol or add an extra conversion layer — neither delivers the same experience as direct connection.
Step-by-Step: Adding a Codex Provider in CC Switch
- Open CC Switch and navigate to the Codex tool page (not the Claude Code page) using the top navigation bar.
- Go to Provider Management → Add Provider.
- Select OpenAI Compatible / Responses Format as the protocol (make sure it uses
/v1/responses, not the Anthropic format). - Fill in the parameters:
- Name: e.g.,
TeamoRouter-Codex - Base URL: The gateway address of your provider (confirm it supports
/v1/responses) - API Key: Your unique API key
- Name: e.g.,
- Save and wait for CC Switch's health check to pass.
- Return to the Codex tool page and switch the default Provider to the one you just added.
- Fully restart the Codex CLI (most CLIs don't hot-reload environment variables) for the new configuration to take effect.
Pro tip: If you get a 404 after setup, first check whether the baseUrl is missing /v1 and whether you accidentally selected the Anthropic protocol format. A 400 error usually means the Codex version doesn't match the protocol endpoint — upgrade Codex to a version that supports Responses.
Relay vs. Direct Connection in CC Switch: What's the Difference
| Aspect | Relay (Protocol Conversion Layer) | Direct Connection (Native /v1/responses) |
|---|---|---|
| Protocol path | responses → chat completions conversion | Native /v1/responses passthrough |
| Tool calling / reasoning features | May break or behave inconsistently | Fully preserved |
| Stability | Extra conversion layer, more failure points | Shorter path, more stable |
| Setup complexity | Requires checking conversion compatibility | Just fill in a baseUrl |
| Best for | When upstream only supports older protocols | First choice |
Bottom line: Use direct connection whenever possible. As long as your provider natively supports /v1/responses, filling in a single baseUrl in CC Switch lets Codex perform at its full potential — no need to tolerate the feature loss and extra failure points of a relay conversion layer.
Connect Codex with a Single TeamoRouter BaseUrl
TeamoRouter, an LLM unified gateway designed natively for AI agents, natively supports Codex's Responses protocol for direct connection:
- 100% Agent protocol compatible: Full support for Codex's
/v1/responses, Tool Calling, and various Beta features — no lossy conversion. - Single baseUrl direct connection: Just fill in the Base URL and API Key in CC Switch, or skip CC Switch entirely and
exportdirectly to Codex — one fewer local routing layer means one fewer class of proxy conflicts and reconnecting issues. - >99% cache hit rate, no model substitution: No account pool rotation. Combined with a 1-2x real-time floating rate, Codex can run tasks all night with predictable bills.
- Enterprise-grade high availability: 99.6% SLA, up to 5000 QPM concurrency, time-to-first-token approaching direct API levels.
For complete step-by-step instructions with screenshots, see the CC Switch setup and TeamoRouter configuration guide. To learn how to choose a provider that doesn't cut corners, check out Recommended relay API providers for CC Switch. If reconnecting issues are bothering you, see the complete reconnecting troubleshooting guide.
Frequently Asked Questions
What protocol format should I choose for Codex in CC Switch?
Select OpenAI Compatible / Responses Format, ensuring it uses /v1/responses. Don't accidentally choose the Anthropic format used for Claude Code. Selecting the wrong protocol is the most common cause of 400/404 errors when connecting Codex.
Which is better for Codex: relay or direct connection?
Use direct connection whenever possible. Direct connection natively passes through /v1/responses, preserving full tool calling and reasoning capabilities with a shorter, more stable path. Relay requires protocol conversion, which can lose features and introduce extra failure points. The prerequisite is that your provider natively supports the Responses protocol.
Can one baseUrl work with both Claude Code and Codex?
Yes — as long as the gateway supports both the Anthropic and OpenAI Responses protocols. TeamoRouter supports both, so you can use the same credentials in CC Switch to configure separate providers for Claude Code and Codex, choosing the correct protocol format for each tool.