selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

9Router logo

Self-host 9Router

v0.5.35

AI gateway routing coding CLIs to 60+ LLM providers

BetaOpen SourceMIT
docker run -d --name 9router -p 20128:20128 -v "$HOME/.9router:/app/data" -e DATA_DIR=/app/data decolua/9router:latest
Updatedlast month
LanguageJavaScript
Setup difficultyEasy
Stars
32 505
Port
20128 (Web dashboard and the OpenAI-compatible /v1 API)
Docker
decolua/9router

What is 9Router?

9Router is an MIT-licensed gateway that sits between coding tools such as Claude Code, Codex, Cursor, Cline, OpenClaw, Continue and Roo and a large catalog of model providers, exposing a single OpenAI-compatible API on your own machine. Requests follow user-built combos that step down automatically from subscription accounts to cheap providers and then to free ones, so an exhausted quota does not halt a session. It compresses tool output (git diff, grep, directory listings) before the request leaves, appends terseness prompts to shrink replies, tracks per-provider quota and token usage, balances several accounts per provider, refreshes upstream OAuth tokens by itself, and rewrites payloads between OpenAI, Anthropic, Gemini, Kiro, Vertex and other shapes. Chat is only one of nine service kinds: embeddings, speech synthesis and recognition, image and video generation, web search and page fetching are routed too, and self-hosted speech or embedding servers can be fronted. Run it with a global npm install, with the published amd64/arm64 container image plus a data volume for the embedded SQLite state, or from source on a VPS behind PM2. Worth knowing before you rely on it: upstream free tiers come and go (the docs note several that were discontinued during 2026), and the money figures in the dashboard are savings estimates rather than bills.

Should you self-host 9Router?

9Router scores 68/100 on selfhost.directory (how scoring works) and ranks #3 of 7 in LLM Integration. It has 32 505 GitHub stars, +1 375 in the last 30 days.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in JavaScript.

Its closest alternative on selfhost.directory is private-gpt (80/100, 57 639 stars). It scores higher overall, so compare the two before you pick. See 9Router vs private-gpt side by side.

Features

  • Automatic OAuth token refresh
  • Automatic provider fallback
  • Cloud sync of configuration
  • Cross-provider format translation
  • Custom model combos
  • Input token compression
  • MITM bridge for IDE subscriptionsProject notes each tool's own policy must be respected.
  • Multi-account load balancing
  • Multimodal endpoint routing
  • OpenAI Compatible API
  • Outbound proxy support
  • Output token saving prompts
  • Quota and usage tracking
  • Request logging
  • Web Dashboard

9Router README

9Router Dashboard

9Router - FREE AI Router & Token Saver

Never stop coding. Save 20-40% tokens with RTK + auto-fallback to FREE & cheap AI models.

Connect All AI Code Tools (Claude Code, Cursor, Antigravity, Copilot, Codex, Gemini, OpenCode, Cline, OpenClaw...) to 40+ AI Providers & 100+ Models.

npm Downloads Docker Pulls GHCR License

decolua%2F9router | Trendshift

🚀 Quick Start • 💡 Features • 📖 Setup • 🌐 Website

🇧🇷 Português (Brasil) • 🇻🇳 Tiếng Việt • 🇨🇳 中文 • 🇯🇵 日本語 • 🇷🇺 Русский • 🇹🇭 ไทย • 🇮🇷 فارسی • 🇮🇩 Indonesia • 🇪🇸 Español • 🇫🇷 Français


🤔 Why 9Router?

How to install 9Router

Install 9Router with Docker

Environment variables
DATA_DIR, PORT, HOSTNAME, JWT_SECRET, INITIAL_PASSWORD, REQUIRE_API_KEY, ENABLE_REQUEST_LOGS, AUTH_COOKIE_SECURE
docker run -d \
  --name 9router \
  -p 20128:20128 \
  -v "$HOME/.9router:/app/data" \
  -e DATA_DIR=/app/data \
  decolua/9router:latest

Multi-platform images (linux/amd64 and linux/arm64) on Docker Hub and GHCR; container defaults are PORT=20128 and HOSTNAME=0.0.0.0.

How to configure 9Router

  • JWT_SECRETAuto-generated (~/.9router/jwt-secret)JWT signing secret for dashboard auth cookie (override to share across instances)
  • INITIAL_PASSWORD123456First login password when no saved hash exists
  • DATA_DIR~/.9routerMain app data location (SQLite at `$DATA_DIR/db/data.sqlite`)
  • PORTframework defaultService port (`20128` in examples)
  • HOSTNAMEframework defaultBind host (Docker defaults to `0.0.0.0`)

FAQ

What if my usage suddenly spikes?

Fallback cascades from subscription to cheap to free as limits are hit, and you can set spending caps per provider in the dashboard.

How do I minimize my actual AI costs?

Begin with a combo made only of free-tier models, add a cheap pay-per-token provider as backup if you need headroom, and use paid subscriptions last.

Are FREE providers really unlimited?

Mostly, but each free offering is capped by its vendor, and some former free tiers (iFlow, Qwen Code, Gemini CLI) have been withdrawn, so availability shifts over time.

Will I be charged by 9Router?

No. The router is free software running locally with no billing system; subscription and pay-per-token charges go straight to the providers.

Why does my dashboard show high costs?

The dashboard prices your usage as if the same tokens had gone through paid APIs; it is a savings comparison, not an invoice.

More in LLM Integration

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…