ccg-router / Tutorials

Use one local router for Claude Code and Codex CLI

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.

Install

brew install XZXY-AI/tap/ccg-router

You can also use the shell installer or Go install from the GitHub repository.

Initialize config

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.

Point both CLIs at the local daemon

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.

Start the router

ccg-router start
Current limit: v0.1 supports non-streaming requests. Streaming passthrough is planned for v0.2.

Verify

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/.

Why this helps