Free AI router and token saver. Point Claude Code, Cursor, Codex or Cline
at one OpenAI-compatible endpoint. Auto-fallback, RTK, usage dashboard.
Why · Features · Architecture · Quick start · Docker · Config
One gateway. Many providers. No vendor lock-in in the IDE.
Rate limits kill a coding session. ERouter sits in front of 40+ providers, keeps an OpenAI-shaped /v1 API, and fails over when the primary key is exhausted.
| Pain | What ERouter does |
|---|---|
| One provider hits 429 | Auto-fallback down the configured list |
| Every tool wants a different base URL | OpenAI-compatible /v1/chat/completions |
| Tokens disappear into the void | RTK + basic cost tracking + dashboard |
| Keys live in five IDE settings | One self-hosted gateway |
Provider order is fallback priority. First entry is preferred. If every provider is rate-limited, the router returns a clear error instead of hanging. Start with 2–3 providers and reorder later in the dashboard or config.
| Smart fallback across 40+ upstreams. No client changes. | Reduce wasted tokens. Track rough cost from the dashboard. |
| Monitor usage, reorder providers, inspect requests. | Claude Code, Cursor, Codex, Cline — point them at the local `/v1`. |
| Next.js app + Docker Compose. Your keys stay on your machine. | Packed CLI under cli/ for install and ops workflows. |
flowchart LR
IDE["Claude Code / Cursor / Codex / Cline"] --> GW["ERouter /v1"]
GW --> D["Dashboard"]
GW --> P1["Provider A"]
GW --> P2["Provider B"]
GW --> P3["Provider N"]
P1 -.->|429 / down| P2
P2 -.->|429 / down| P3
git clone https://github.com/awhite0030/ERouter.git
cd ERouter
cp .env.example .env
npm install
npm run devDev server listens on port 20127.
curl http://localhost:20127/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}]}'Full setup: docs/. Docker: DOCKER.md. CI: CI-CD.md.
cp .env.example .env
docker compose up --buildProduction-oriented env uses PORT=20128 and DATA_DIR=/var/lib/erouter.
| Variable | Purpose |
|---|---|
JWT_SECRET |
Auth secret — set a long random value |
INITIAL_PASSWORD |
First admin password |
DATA_DIR |
Persistent data directory |
PORT |
HTTP port (20128 in the Docker contract) |
API_KEY_SECRET |
Endpoint proxy API key secret |
REQUIRE_API_KEY |
Require API keys on /v1 |
ENABLE_REQUEST_LOGS |
Verbose request logging |
OBSERVABILITY_ENABLED |
Metrics / observability switch |
BASE_URL |
Public URL of this instance |
HTTP_PROXY / HTTPS_PROXY |
Outbound proxy for upstream calls |
Never commit real keys. .env is gitignored.
PRs welcome. Chinese docs: README.zh-CN.md.
ERouter is a rebranded MIT derivative of 9router.
MIT © 2026 A. White / ERouter contributors