CC Reverse Proxy Access Guide: Connect Claude Code and Codex via the Same Gateway

  • 发布时间
  • 语言en

Using local reverse proxies like cc-switch or claude-code-proxy, you can forward Claude Code (Anthropic) and Codex (OpenAI) to our gateway with a single key and unified billing.

I. What is this

CC Reverse Proxy (commonly known as cc-switch, claude-code-proxy, etc.) is a type of local/self-hosted forwarding proxy: it provides a unified entry point (Anthropic / OpenAI compatible) and forwards requests to your upstream provider. This allows your local Claude Code (Anthropic) and Codex (OpenAI) to connect to the same reverse proxy, flowing through our gateway using a single sk- API key and balance.

When your local Claude Code (Anthropic) and Codex (OpenAI) need to use our gateway, the reverse proxy routes the requests to a unified entry point, allowing you to manage everything with one API key and balance.

II. Preparation

  1. Log in to the API console, create an sk-… API Key (it is displayed only once, please save it).
  2. Confirm the model slugs you intend to use (one for Claude and one for GPT, or as needed).
  3. Confirm the gateway address: https://www.relay-api.com.

III. Configuring the CC Reverse Proxy

① Install and start

npm install -g cc-switch   # or claude-code-proxy / corresponding reverse proxy tool
cc-switch start            # Default local port 127.0.0.1:8787

② Point the proxy "upstream" to our gateway (The two core items: upstream address + API key). Using cc-switch configuration as an example:

# cc-switch configuration example
anthropic_upstream = "https://www.relay-api.com"
openai_upstream    = "https://www.relay-api.com/v1"
api_key            = "sk-your-key"

③ Connect Claude Code and Codex respectively (pointing to the proxy's local port):

export ANTHROPIC_BASE_URL="http://127.0.0.1:8787"
export ANTHROPIC_API_KEY="sk-your-key"
export ANTHROPIC_MODEL="claude-sonnet-5"
claude
export OPENAI_BASE_URL="http://127.0.0.1:8787"
export OPENAI_API_KEY="sk-your-key"
codex --model gpt-5.5

IV. Upstream Endpoint Reference

UsageUpstream Base URL
Claude Code (Claude)https://www.relay-api.com
Codex (GPT)https://www.relay-api.com/v1

V. FAQ

IssueSolution
401 / 403Key invalid or insufficient balance; confirm the sk- key is correct and check your balance.
404 / Model InvalidEnsure the upstream address points to our site's entry; verify the model is enabled.

Security Tip: Do not commit your platform sk- keys to public repositories; it is recommended to create a dedicated key for your reverse proxy to facilitate tracking and rate limiting.

Base URL Note: Our site accepts both /v1beta/models/... and /v1beta/v1beta/models/... (as well as /v1/... and /v1/v1/...), so it does not matter if the client appends /v1 or /v1beta; the Base URL works whether you input the domain root or the address including /v1beta. Please find and copy the Model ID from the "Model ID" section in the top right corner of the "Tokens" page in the console.