- 📖 User Guide — Installation, minimal setup, the semantics of every config field and troubleshooting. (Currently in Chinese)
- 🏗️ Architecture Framework — The design patterns underneath (Template Method, Circuit Breaker, State Machine, etc.), for anyone who wants to peek under the hood or contribute a vendor. (Currently in Chinese)
| Topic | Documents |
|---|---|
| Hands-on guides | Quick Start · Vendors · CLI Reference · HTTP API · Dashboard · Monitoring & Troubleshooting |
| Architecture | Design Patterns · Routing · Vendors · Protocol Conversion · Config Reference · Session Model Bind · Subscription Status · Testing |
| Operations & design | CI/CD · Config Tab UX · Diagrams |
When you're deeply immersed in your coding "zone" with Claude Code (or any AI assistant relying on Anthropic's Messages API), there's nothing quite as soul-crushing as having your flow violently interrupted by:
- 🛑 Rate Limiting: High-frequency pings trigger the dreaded
429 rate_limit_error. Forced to stare at the screen and rethink your life choices. - 💸 Usage Cap: Aggressive code generation drains your daily/monthly quota, slamming you with a cold, heartless
403error. - 🌋 Overloaded Servers: Anthropic's official servers melt down during peak hours, tossing back a merciless
503 overloaded_error.
coding-proxy was forged in the developer fires to terminate these exact pain points. Serving as a purely transparent intermediate layer, it blesses your Claude Code with millisecond-level "N-tier chained fallback disaster recovery." When your primary vendor goes belly up, it seamlessly and instantly switches your requests to the next smartest available fallback (like GitHub Copilot, Google Antigravity, or even Zhipu GLM)—with zero manual intervention, and zero perceived interruption.
- ⛓️ N-tier Chained Failover: Autonomous descending sequence, supporting Claude's official plans, as well as Coding Plans from GitHub Copilot, Google Antigravity, Z AI, MiniMax, Alibaba Qwen, Xiaomi, Kimi, Doubao, etc. Reorder the chain at runtime from the Dashboard, the CLI (
reset -v,session bind) or per-session policies. - 🛡️ Smart Resilience & Quota Guardians: Every single vendor node comes fully armed with an independent Circuit Breaker and Quota Guard to proactively dodge avalanches without breaking a sweat.
- 👻 Phantom-like Transparency: 100% transparent to the client! No code tweaks required. Overwrite
ANTHROPIC_BASE_URLwith a single line, and you're good to go. - 🔄 Universal Alchemy (Formats & Models): Native support for two-way request/streaming (SSE) translation between Anthropic ←→ Gemini and Anthropic ←→ OpenAI, plus a native Gemini-protocol pass-through gateway for Antigravity clients. Session affinity and tool-call mapping are preserved across vendors, and model names map automatically or by hand (e.g.,
claude-*→glm-*). - 📊 Extreme Observability: Built-in, zero-BS local monitoring powered by a
SQLite WAL. The CLI provides a one-click detailed Token usage dashboard (coding-proxy usage). - ⚡ Featherweight Standalone Deployment: A fully asynchronous architecture (
FastAPI+httpx). Zero dependency on Redis, message queues, or other heavy machinery—absolutely no extra baggage for your dev rig.
Make sure your rig has Python 3.12+ and the uv package manager installed (highly recommended, because life is too short for slow package managers).
uv tool install coding-proxy(From source: uv sync inside the repository, then prefix the commands below with uv run.)
The default chain is zhipu → anthropic → copilot → antigravity; the Zhipu key is read from ${ZHIPU_API_KEY}. Inject it via env var, or store it encrypted in the config store (never echoed back):
# Option A: env var
export ZHIPU_API_KEY="sk-..."
# Option B: encrypted config store
# echo -n "sk-..." | coding-proxy config set-secret vendors.zhipu.api_key --stdin
# anthropic works with your Claude Code / PI login token (passed through); Copilot and Antigravity need a one-time OAuth login
# (provider is `github` for Copilot, `google` for Antigravity; omit -p to log in to both):
# coding-proxy auth login -p githubStart the proxy:
coding-proxy start
# INFO: coding-proxy started: host=127.0.0.1 port=3392
# INFO: Uvicorn running on http://127.0.0.1:3392 (Press CTRL+C to quit)Runtime config lives in ~/.coding-proxy/config.db (SQLite, secrets encrypted) — edit it via the Dashboard → Config page or the coding-proxy config CLI; there is no YAML to manage (config path lists every file in play, config export dumps the effective config as redacted YAML). An existing ~/.coding-proxy/config.yaml from older versions is imported once on first start (start -c ./coding-proxy.yaml to pick a specific file).
Claude Code — redirect its Anthropic endpoint; your Claude Code OAuth token is passed through to Anthropic, no extra auth needed:
export ANTHROPIC_BASE_URL=http://127.0.0.1:3392
claudePI — PI has no env redirect; its built-in anthropic provider must point at the proxy. Open Dashboard → Config → Clients → PI → 「写入 models.json」 to merge this into ~/.pi/agent/models.json for you (or paste it yourself):
export CODING_PROXY_TOKEN="coding-proxy" # PI requires a non-empty apiKey; the proxy does not check it{
"providers": {
"anthropic": {
"baseUrl": "http://127.0.0.1:3392",
"apiKey": "$CODING_PROXY_TOKEN",
"compat": { "sendSessionAffinityHeaders": true, "sessionAffinityFormat": "openrouter" }
}
}
}If you previously ran /login for Anthropic inside PI, run /logout anthropic first (auth.json takes precedence). Both clients share the same vendor chain — model mapping, failover, Model Bind and usage/cost stats apply identically. Verify with coding-proxy status (circuit-breaker / quota state) and coding-proxy usage (token spend per client / vendor / model).
Open http://127.0.0.1:3392/dashboard for real-time token spend, latency and circuit-breaker state. The Config tab edits the whole configuration online (vendors, tier order, failover, model mapping, pricing, native API, session policies, Antigravity gateway, clients, system); saves hot-swap the running proxy with zero restarts. Unlock it once with the admin token printed by coding-proxy config token.
| Config tab | Sessions | Model Calling |
|---|---|---|
![]() |
![]() |
![]() |
coding-proxy comes equipped with a badass suite of CLI tools to help you boss around your proxy state.
| Command | Description | Example Usage |
|---|---|---|
start |
Fire up the proxy server. -p / -h for port and bind address; -c for a one-time legacy YAML import. |
coding-proxy start -p 8080 |
config |
Manage the config store (~/.coding-proxy/config.db). Sub-commands: set, reset, set-secret (encrypted; --stdin, --env, --clear, --default-env), import / export (YAML, secrets redacted), path, token (Dashboard admin token). |
coding-proxy config set vendors.zhipu.timeout_ms 60000 |
auth |
Manage OAuth credentials. Sub-commands: login (browser OAuth; -p github for Copilot, -p google for Antigravity, both when omitted), status, reauth, logout. |
coding-proxy auth login -p github |
status |
Check proxy health. Shows circuit-breaker states (OPEN/CLOSED) and quota status across all tiers. | coding-proxy status |
session |
Session-level routing overrides. bind pins vendor order (and optionally a model) to a session key, unbind releases it, list shows what is bound. Same data as the Model Bind column on the Dashboard. |
coding-proxy session bind --help |
usage |
Token stats dashboard. Tokens, failovers and latency by day (-d), week (-w), month (-m) or all history (-t), filtered by vendor (-v) or served model (--model). |
coding-proxy usage -d 7 -v anthropic |
reset |
The emergency flush button. Force-reset all circuit breakers and quotas; -v additionally promotes / reorders vendors so the recovered one is tried first. |
coding-proxy reset -v zhipu |
When a request inevitably hits the fan, the RequestRouter slides gracefully down the N-tier tree, juggling circuit breakers and token quotas to decide the ultimate destination:
For a deep dive into the architecture and under-the-hood wizardry, consult framework.md (Currently in Chinese).
To ensure this project outlives us all (long-term maintainability), we offer exhaustive, Evidence-Based documentation:
- 📖 User Guide — From installation and bare-minimum setup to the semantic breakdown of every config field and common troubleshooting manuals. (Currently in Chinese)
- 🏗️ Architecture Framework — A meticulous decoding of underlying design patterns (Template Method, Circuit Breaker, State Machine, etc.), targeted at devs who want to peek into the matrix or contribute new vendors. (Currently in Chinese)
During our chaotic yet rewarding exploration of engineering practices, we were heavily inspired by cutting-edge tech ecosystems and brilliant designs. Special shoutouts:
- A massive thank you to Claude Code for sparking our obsession with crafting the ultimate, seamless programming assistant experience.
- Endless gratitude to the open-source community's myriad of API Proxy projects. Your trailblazing in reverse proxies, high-availability setups (circuit breakers/streaming proxies), and dynamic routing provided the rock-solid theoretical foundation for
coding-proxy's elastic N-Tier mechanisms.



