@sifxprime/krouter
v0.5.164
Published
Local AI gateway for Claude Code, Cursor, Codex, Copilot, Cline and any OpenAI-compatible client. Route 40+ LLM providers and 100+ models through one endpoint with automatic fallback, OAuth key management and 20-40% token savings.
Maintainers
Readme
kRouter — Kodelyth AI Infrastructure
The universal AI router that saves 20–40% input tokens and falls back when a provider fails.
Connect Claude Code, Cursor, Antigravity, Kiro, Copilot, Codex, OpenCode, Cline, OpenClaw, and any OpenAI-compatible client to 95+ AI providers and 100+ models through one self-hosted endpoint. Route intelligently. Fall back instantly. Save tokens automatically.
Website & Full Docs — krouter.kodelyth.com
Quick Start • Features • Setup • Supported Providers
You're viewing this on npm. Full docs, screenshots, and changelog: github.com/sifxprime/krouter.
Quick Start
Requires Node.js 20.9 or newer.
# Install globally from npm
npm install -g @sifxprime/krouter
# Run in background (tray mode)
krouter -tThe dashboard is at http://localhost:20128/dashboard — open it in your browser, or from the tray icon.
First login: the default dashboard password is 123456. Change it under Settings → Security once you're in.
For safety, the default only works from the machine kRouter is running on — sign-ins from other devices
on your network are refused until you set your own. Under Docker that includes your own browser, so
set INITIAL_PASSWORD as shown below.
Prefer the foreground? Run krouter with no flag, and add -l to see the server logs.
CLI Options
krouter --help
Options:
-p, --port <port> Port to run the server (default: 20128)
-H, --host <host> Host to bind (default: 0.0.0.0)
-l, --log Show server logs (default: hidden)
-t, --tray Run in system tray mode (background)
--skip-update Skip auto-update check
-h, --help Show this help message
-v, --version Show versionThe default host 0.0.0.0 makes kRouter reachable from your network; remote callers still need an API key
for /v1/* and a login for the dashboard. Use --host 127.0.0.1 to keep it local-only. The krouter
command ignores the PORT and HOSTNAME environment variables, so set the port and host with these flags.
From Source (Contributors)
git clone https://github.com/sifxprime/krouter.git
cd krouter
npm install
npm run devDocker
KROUTER_PASSWORD="$(openssl rand -base64 18)" && echo "Dashboard password: $KROUTER_PASSWORD"
docker run -d \
-p 20128:20128 \
-e INITIAL_PASSWORD="${KROUTER_PASSWORD:?run the line above first}" \
-v "$HOME/.krouter:/app/data" \
--name krouter \
sifxprime/krouter:latestThe first line makes a random password and prints it. Log in with it, then set your own under
Settings → Security; until you do, the password is whatever INITIAL_PASSWORD the container started with.
Under Docker the default 123456 is refused, because your browser's requests reach the container
from outside it. If ~/.krouter already holds a password from an npm install, that one is used.
Forgot it? With image 0.5.162 or newer: docker exec krouter node scripts/reset-password.js (see
DOCKER.md).
With PII Redaction (Presidio)
To enable automatic PII redaction before sending requests to AI providers. Compose builds kRouter
and the sidecar from source, so it runs from a clone. KROUTER_INITIAL_PASSWORD has no default —
compose refuses to start without it. The second line saves a random one to .env, where compose
reads it on every start, and prints it: that is your dashboard password.
git clone https://github.com/sifxprime/krouter.git && cd krouter
echo "KROUTER_INITIAL_PASSWORD='$(openssl rand -base64 18)'" > .env && cat .env
docker compose up -dNot using Docker? kRouter has no Python dependency — run the sidecar separately. kRouter looks for it
at http://127.0.0.1:5001/redact; set SIDECAR_URL if it runs anywhere else. See the setup guide below.
Redaction is off by default; enable it from the Presidio page in the dashboard sidebar.
See docs/REDACTION_SETUP.md for full configuration and customization options.
Then open http://localhost:20128/dashboard.
Why kRouter?
Stop wasting money, tokens, and hitting limits:
- Subscription quota expires unused every month
- Rate limits stop you mid-coding
- Tool outputs (git diff, grep, ls…) burn tokens fast
- Paying separately for every provider's API adds up
- Manually switching between providers
kRouter solves this:
- RTK Token Saver — on by default; compresses tool outputs to save 20–40% of input tokens per request
- Zenith routing — scores each account by success rate, latency and remaining quota, and skips accounts that are cooling down
- Multi-account rotation — round-robin across accounts, with quota tracking for providers that report it
- Auto token refresh — OAuth tokens refresh transparently
- Universal client support — works with OpenAI, Anthropic, Responses, Gemini and Ollama-format clients
- MITM interception — routes Antigravity, GitHub Copilot, Kiro IDE and Claude Desktop through kRouter (not inside Docker)
How It Works
┌─────────────┐
│ Your CLI │ (Claude Code, Codex, OpenClaw, OpenCode, Cline…)
│ Tool │
└──────┬──────┘
│ http://localhost:20128/v1
↓
┌─────────────────────────────────────────────┐
│ kRouter (Smart Router) │
│ • RTK Token Saver (cut tool_result tokens) │
│ • Zenith account scoring │
│ • Format translation (OpenAI ↔ Claude) │
│ • Live quota tracking │
│ • Auto token refresh │
└──────┬──────────────────────────────────────┘
│
├─→ [SUBSCRIPTION] Claude Code · Codex · Copilot · Cursor
│
├─→ [FREE TIER] Cloudflare · Vertex · Gemini · Ollama Cloud · OpenRouter
│
└─→ [FREE] Kiro · Gemini CLI · Qoder · OpenCode Free · MiMo Code FreeIf an account fails or hits a rate limit, kRouter moves to the next account for that provider. Put models from several providers in a combo and it falls back across them in turn — with zero manual intervention.
PII Redaction with Presidio
Optional, and off by default. When enabled, kRouter strips personal data — names, emails, phone
numbers, API keys — from prompts before they leave your machine, using Microsoft Presidio as a local
sidecar (needs Docker or Python). It fails closed: if the sidecar is down, times out or errors,
the request is rejected (503 / 502) rather than sent unredacted. It covers the chat, Messages,
Responses, Ollama and Gemini-format routes; embeddings, audio, images, search and fetch are not redacted.
Setup, configuration, custom patterns, testing and troubleshooting: docs/REDACTION_SETUP.md.
Features
| Feature | What It Does | Why It Matters | |---------|--------------|----------------| | RTK Token Saver | Compresses tool outputs (git diff, grep, ls, tree…) in requests. On by default | Save 20–40% input tokens on requests that carry tool output | | Zenith Routing | Scores accounts by success rate, latency, remaining quota and priority | Picks the healthiest account; rate-limited accounts cool down instead of being retried | | Smart Fallback | Combos you build, e.g. Subscription → Free tier → Free | Never stop coding | | Real-Time Quota | Remaining %, reset countdown, exhaustion badge for providers that report quota | Maximize every subscription | | Format Translation | OpenAI ↔ Claude ↔ Gemini ↔ Cursor ↔ Kiro ↔ Vertex | Works with any CLI tool | | Multi-Account | Multiple accounts per provider with rotation strategies | Load balancing + redundancy | | Auto Token Refresh | OAuth tokens refresh automatically | No manual re-login | | Custom Combos | Named model combinations with fallback, round-robin or fusion strategy | Tailor fallback to your workflow | | System Tray | Runs quietly in background with tray icon | Set-and-forget deployment | | Deploy Anywhere | Localhost · VPS · Docker · PM2, with remote access through Cloudflare Tunnel or Tailscale | Wherever you need it | | PII Redaction | Optional, off by default: redacts names, emails, phones and API keys using Microsoft Presidio | Protect privacy before sending to AI providers |
Full feature guide → krouter.kodelyth.com
Supported CLI Tools
Supported Providers
95+ providers in five groups, plus any OpenAI- or Anthropic-compatible endpoint you add yourself.
OAuth (Bring Your Subscription)
Claude Code · Antigravity · Codex · GitHub Copilot · Cursor · xAI · Kilo Code · Cline · ClinePass · Grok CLI · Kimchi
Free Tier (with API key)
Cloudflare Workers AI · Vertex AI · Gemini · Ollama Cloud · OpenRouter · BytePlus ModelArk · Atomesus · NVIDIA NIM · Poolside
Free (account sign-in or no auth)
Kiro AI · Gemini CLI · CodeBuddy CN · Qoder · OpenCode Free · MiMo Code Free
Kiro, Gemini CLI, Qoder, Claude Code, Antigravity, Codex and GitHub Copilot use subscription sessions that are not licensed for proxy use. The dashboard warns before you connect them: the account may be restricted or banned.
API Key Providers (65+)
OpenAI · Anthropic · GLM · Kimi · MiniMax · DeepSeek · Groq · xAI · Mistral · Perplexity · Together AI · Fireworks · Cerebras · Cohere · SiliconFlow · Hyperbolic · Nebius · Chutes · and 45+ more
Browser Session
Grok Web · Perplexity Web (Pro/Max)
Full provider setup guide → krouter.kodelyth.com
Setup Guide
Step 1 · Install
npm install -g @sifxprime/krouterStep 2 · Start in Background
krouter -tYou'll see a tray icon in your menu bar. Right-click for Open Dashboard or Quit.
Step 3 · Add a Provider
- Open http://localhost:20128/dashboard
- Go to Providers, pick one (Cloudflare Workers AI is a good free start) and click Add
- Paste your API key or complete the OAuth login
- Click Test on a model to check it answers
Step 4 · Point Your AI Tool at kRouter
Endpoint: http://localhost:20128/v1
API Key: a key from Dashboard → Endpoint → API Keys (local callers can skip it)
Model: kr/claude-sonnet-4.5 (or any provider/model)Works with any OpenAI-compatible client. A Default Key is created the first time you open the
Endpoint page. Local requests need no key unless REQUIRE_API_KEY=true; requests from other machines
always do. Cursor is the exception to localhost: it sends requests through its own servers, so turn
on the Tunnel on the Endpoint page and use that URL with a key.
Detailed integration guide (Claude Code, Cursor, Cline, and more) → krouter.kodelyth.com
Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| PORT | 20128 | Server port for the Docker image and node custom-server.js. The krouter command ignores it — use --port |
| HOSTNAME | 0.0.0.0 | Bind host for the Docker image and node custom-server.js. The krouter command ignores it — use --host 127.0.0.1 for local-only |
| DATA_DIR | ~/.krouter | Data directory (SQLite, certs, cache). %APPDATA%\krouter on Windows |
| INITIAL_PASSWORD | — | First-login dashboard password. Unset, it is 123456, accepted only from the same machine |
| NODE_ENV | production | Runtime mode |
| REQUIRE_API_KEY | false | Require a Bearer key on /v1/* from every caller. Remote callers always need one; this additionally removes the loopback exemption, for shared or multi-user machines |
| KROUTER_SKIP_RUNTIME_HEAL | false | Skip the startup npm self-heal of the SQLite/tray runtime (air-gapped or CI machines) |
| AUTH_COOKIE_SECURE | false | Force Secure cookie (set behind HTTPS reverse proxy) |
| HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY | — | Outbound proxy config |
Full env reference → krouter.kodelyth.com
Deployment
VPS
npm install -g @sifxprime/krouter
krouter --skip-update --host 127.0.0.1 --port 20128Put Nginx or Caddy in front for HTTPS; --host 127.0.0.1 keeps the port closed to everything but the
proxy. Or skip the proxy and use the built-in Cloudflare Tunnel or Tailscale from the Endpoint page.
Docker
KROUTER_PASSWORD="$(openssl rand -base64 18)" && echo "Dashboard password: $KROUTER_PASSWORD"
docker run -d -p 20128:20128 -e INITIAL_PASSWORD="${KROUTER_PASSWORD:?run the line above first}" -v "$HOME/.krouter:/app/data" --name krouter sifxprime/krouter:latestPM2
npm install -g @sifxprime/krouter pm2
pm2 start krouter --name krouter -- --skip-update
pm2 save
pm2 startupAPI
Chat Completions
POST http://localhost:20128/v1/chat/completions
Authorization: Bearer <your-api-key>
Content-Type: application/json
{
"model": "kr/claude-sonnet-4.5",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}List Models
GET http://localhost:20128/v1/models
Authorization: Bearer <your-api-key>Returns every configured provider + custom combo in OpenAI format.
Uninstall
# Stop kRouter (right-click tray → Quit, or pkill -f krouter)
npm uninstall -g @sifxprime/krouter
rm -rf ~/.krouter # optional: wipe database + certsTroubleshooting
"No active credentials for provider" — Add or reconnect the provider in Dashboard → Providers.
Rate limited — kRouter cools the account down and moves to the next one. To speed it up, add more accounts or configure a combo.
MITM cert errors — Install or reinstall the root CA from the MITM page in the dashboard sidebar (Install Certificate / Reinstall Certificate).
Dashboard on wrong port — the krouter command ignores PORT; pass the port as a flag: krouter -t --port 20128. If another program holds the port, kRouter will not stop it and suggests another one.
Full troubleshooting guide → krouter.kodelyth.com
Tech Stack
- Runtime: Node.js 20.9+
- Framework: Next.js 16
- UI: React 19 + Tailwind CSS 4
- Database: SQLite (better-sqlite3 / node:sqlite / sql.js)
- Streaming: Server-Sent Events (SSE)
- Auth: OAuth 2.0 (PKCE) + JWT + API Keys
Links
- Website: krouter.kodelyth.com
- GitHub: github.com/sifxprime/krouter
- Issues: github.com/sifxprime/krouter/issues
- npm:
@sifxprime/krouter - Support: [email protected] · WhatsApp
Credits
kRouter is a hardened fork of the upstream decolua/9router. Huge thanks to @decolua and the 9router contributors for the original project. Star them on GitHub.
License
MIT License — see LICENSE for details.
