中文 · English
One local router for Claude Code and Codex CLI. An OpenAI-compatible and Anthropic-compatible proxy with shared upstreams, routing strategies, and a local SQLite usage ledger.
ccg-router runs on 127.0.0.1, accepts Anthropic-compatible and OpenAI-compatible requests, routes them to the upstreams you configure, and stores usage metadata in a local SQLite ledger. Your provider keys stay in your local config or environment. It is built for developers who use Claude Code, Codex CLI, OpenAI-compatible APIs, and Anthropic-compatible APIs side by side.
If this saves you from switching CLI env vars by hand, starring the repo helps more AI coding users find it.
| Tool | What it does | Difference |
|---|---|---|
claude-code-router |
Routes Claude Code traffic | Single CLI focus |
| Manual switching | Change shell env vars by hand | Slow, inconsistent, no ledger |
ccg-router |
Local routing layer for Claude Code and Codex CLI | One config, shared routing, local usage ledger |
v0.1 is a public preview for non-streaming requests. Streaming passthrough is planned for v0.2.
- Claude Code router endpoint for Anthropic-compatible
/v1/messages - Codex CLI router endpoint for OpenAI-compatible
/v1/chat/completions - Local OpenAI-compatible and Anthropic-compatible proxy on one port
- Routing strategies:
prefer-cheaper,prefer-capable, andround-robin - Local SQLite usage ledger for request metadata
- Signed preset registry loader
- Read-only local dashboard at
/ui/
- Streaming passthrough
- Hosted preset registry
- Encrypted local ledger
- Advanced dashboard analytics
Install with Homebrew, the release installer, or Go:
brew install XZXY-AI/tap/ccg-router
curl -fsSL https://raw.githubusercontent.com/XZXY-AI/ccg-router/main/scripts/install.sh | bash
go install github.com/XZXY-AI/ccg-router/cmd/ccg-router@latestccg-router init
export ANTHROPIC_BASE_URL=http://127.0.0.1:17180
export OPENAI_BASE_URL=http://127.0.0.1:17180
ccg-router startOpen http://127.0.0.1:17180/ui/.
Claude Code sends Anthropic-compatible requests to 127.0.0.1:17180. Codex CLI sends OpenAI-compatible requests to the same daemon. ccg-router normalizes the request, selects an upstream, forwards the raw body, and records a local ledger row.
- Anthropic-compatible
/v1/messages - OpenAI-compatible
/v1/chat/completions - Three routing strategies
- Local SQLite usage ledger
- Signed preset registry loader
- Read-only local UI
| Need | Best fit |
|---|---|
| Route only Claude Code traffic | claude-code-router |
| Share one local routing layer across Claude Code and Codex CLI | ccg-router |
Manually switch ANTHROPIC_BASE_URL and OPENAI_BASE_URL |
Shell env vars |
| Keep provider keys local while using multiple compatible APIs | ccg-router |
People usually find this project while looking for a Claude Code router, Codex CLI router, OpenAI-compatible proxy, Anthropic-compatible proxy, local LLM router, AI coding CLI router, or local Claude Code usage tracking.
- Claude Code router
- Codex CLI router
- OpenAI-compatible proxy
- Anthropic-compatible proxy
- Local usage ledger
- ccg-router vs claude-code-router
- Claude Code router
- Codex CLI router
- Route Claude Code to OpenAI-compatible APIs
- Codex CLI OpenAI-compatible router
- ANTHROPIC_BASE_URL local router
- OPENAI_BASE_URL local router
- Claude Code usage tracking
- Local LLM router for AI coding CLI tools
- Use one local router for Claude Code and Codex CLI
- Run an OpenAI-compatible and Anthropic-compatible local proxy
- Track Claude Code and Codex CLI usage locally
- ANTHROPIC_BASE_URL not working with Claude Code
- OPENAI_BASE_URL not working with Codex CLI
- Homebrew install problem
- go install ccg-router@latest problem
- ccg-router doctor failed
See docs/configuration.md.
See docs/routing-strategies.md.
See docs/preset-registry.md.
- v0.1: local daemon, routing, ledger, registry verification, UI
- v0.2: streaming passthrough, richer local dashboard, more CLI adapters
- Later: encrypted ledger, plugin hooks, deeper usage analytics
See docs/faq.md.
Star the repo: https://github.com/XZXY-AI/ccg-router Discussions: https://github.com/XZXY-AI/ccg-router/discussions Hub: https://github.com/XZXY-AI/awesome-ai-coding-cli
Run make test before opening a PR. Keep public docs focused on local routing, official direct upstream examples, privacy, and reproducible behavior.
Apache-2.0
