Claude Code and Codex CLI can both work with compatible API endpoints, but switching endpoint environment variables by hand is easy to get wrong. ccg-router gives both tools one local routing layer on 127.0.0.1:17180.
This tutorial shows the basic local-first setup. It is useful when you want a Claude Code router, a Codex CLI router, OpenAI-compatible routing, Anthropic-compatible routing, and a local usage ledger in one daemon.
brew install XZXY-AI/tap/ccg-router
You can also use the shell installer or Go install from the GitHub repository.
ccg-router init
The generated config uses official-direct upstream examples. Replace or extend those upstreams with the providers and compatible APIs you actually use. Keep provider keys in environment variables.
export ANTHROPIC_BASE_URL=http://127.0.0.1:17180
export OPENAI_BASE_URL=http://127.0.0.1:17180
Claude Code sends Anthropic-compatible traffic to the local router. Codex CLI sends OpenAI-compatible traffic to the same router. ccg-router selects an enabled upstream, forwards the request, and records request metadata in SQLite.
ccg-router start
ccg-router --version
ccg-router doctor
Use doctor to check config, ledger, and registry health. The local UI is available at http://127.0.0.1:17180/ui/.