One local endpoint for all your Claude Code backends. Set ANTHROPIC_BASE_URL
once, then switch between MiniMax, GLM, Kimi, and Claude without ever editing
settings.json again.
Runs entirely on 127.0.0.1 — your requests never transit a third party you
didn't choose. Zero runtime dependencies; Bun + strict TypeScript.
git clone https://github.com/sano0007/cc-gate.git && cd cc-gate
bun install
bun run build # produces a single self-contained binary at dist/cc-gate
# optional: mv dist/cc-gate ~/.local/bin/ (or anywhere on your PATH)Or run straight from the checkout with bun bin/cc-gate.ts <command>.
-
Run
cc-gate init. An interactive picker appears — arrow keys (or type a few letters to filter) to choose your provider, then enter the API key. "Custom" in the list lets you type a name and base URL by hand. Piping input works too:printf 'claude\nsk-ant-…\n\n' | cc-gate init.cc-gate init
-
Run the proxy. Pass
--write-settingsonce and your~/.claude/settings.jsonwill point Claude Code at cc-gate, with a timestamped backup of the original.cc-gate start --write-settings
-
(Optional) confirm everything is wired up:
cc-gate doctor
You only edit ~/.claude/settings.json once — the --write-settings
flag is idempotent and creates a settings.json.bak.<timestamp> the
first time it runs. Use CLAUDE_SETTINGS_PATH=/path/to/other.json to
target a non-default location.
| How | Example | Effect |
|---|---|---|
/model inside Claude Code |
/model minimax,MiniMax-M3 |
this session, immediately |
| CLI override | cc-gate use minimax |
all sessions, next request |
| Clear override | cc-gate use --clear |
router rules apply again |
| Routing rules | "background": "glm,glm-4.5-air" in config |
automatic per request type |
cc-gate doctor shows what the proxy sees. GET /health reports the active override.
The override takes effect on the next request; in-flight requests complete on the previously-routed provider.
cc-gate init [--force]— scaffold~/.cc-gate/config.json(orCC_GATE_DIR/config.json). Pass--forceto overwrite an existing config.cc-gate start [--write-settings]— run the proxy on 127.0.0.1 (default port 8787). With--write-settings, patchesCLAUDE_SETTINGS_PATH(default~/.claude/settings.json) so Claude Code points at cc-gate.cc-gate use [provider|--clear]— show/set/clear the active providercc-gate doctor— validate config, list providers and aliases
Anthropic-passthrough only: auth swap, beta-header hygiene, alias mapping,
stream watchdog (stalls become clean retryable errors, never hangs). OpenAI
translation, observability, and a status dashboard come later — see
docs/architecture.md for the full design.
Providers without aliases receive the model's literal name as-is; configure aliases to enable haiku/sonnet/opus slot mapping.
- The proxy binds
127.0.0.1only and never logs your API keys (doctormasks all but the last 4 characters). cc-gate initwrites~/.cc-gate/config.jsonwith0600permissions and never echoes the API key while you type it.- Prefer
"api_key": "$MY_ENV_VAR"in the config over literal keys — values starting with$are resolved from the environment at startup. --write-settingsalways backs upsettings.jsonbefore touching it.
bun install
bun test # 113 tests
bun run typecheck # strict TypeScript
bun run build # single-binary compileThe full design/architecture doc lives at docs/architecture.md.