# 9Router

> Local router for coding CLIs with quota tracking, tiered fallback and token compression

- Category: Evaluation & Production Ops / Gateways & Routing
- Language: JavaScript
- Licence: MIT
- Repository: https://github.com/decolua/9router
- Website: https://9router.com
- Canonical page: https://ai-tldr.dev/tools/9router/

## In short

9Router is a self-hosted router that sits between your AI coding tools and the providers behind them. It sits in the Gateways & Routing category of the Evaluation & Production Ops tools and is open-source, written in JavaScript and licensed MIT. To get started: install and start.

## Overview

9Router is a self-hosted router that sits between your AI coding tools and the providers behind them. It exposes an OpenAI-compatible endpoint on `http://localhost:20128/v1`, so any CLI that accepts a custom base URL — Claude Code, Codex, Cursor, Cline, Copilot, OpenCode, Antigravity, OpenClaw — points at it instead of a vendor, and gets access to 40+ providers and 100+ models behind one key.

Its purpose is to keep you from stalling mid-task. It tracks per-provider quota so a paid subscription is used up before it resets, then falls back through tiers automatically — subscription first, then cheap models, then free ones — with no downtime when one runs out. Multiple accounts per provider are rotated round-robin, tokens are refreshed automatically, and request formats are translated between the OpenAI and Claude shapes so the same downstream tool works against either.

A second lever is RTK, a token saver that compresses `tool_result` content — the git diffs, greps and directory listings that dominate an agent's context — before it is sent, which the project reports as 20-40% fewer tokens per request. A dashboard at the same port handles provider connection, quota views and key management.

## What it does

- OpenAI-compatible local endpoint any coding CLI can point at, fronting 40+ providers and 100+ models
- Tiered auto-fallback — subscription, then cheap, then free — so an exhausted quota does not stop a session
- Per-provider quota tracking with automatic token refresh
- RTK token saver that compresses tool_result payloads, reported at 20-40% fewer tokens per request
- Format translation between the OpenAI and Claude request shapes
- Multi-account round-robin per provider
- Web dashboard for providers, quota and keys; npm, Docker and GHCR distributions

## Getting started

Install globally, open the dashboard, connect a provider, then repoint your coding CLI at the local endpoint.

1. Install and start

   The dashboard opens at http://localhost:20128.

```bash
npm install -g 9router
9router
```

2. Connect a provider

   In the dashboard, go to Providers and connect one. Kiro AI and OpenCode Free need no signup, so you can verify the path end to end before wiring up a paid account.

```text
Dashboard -> Providers -> Connect
```

3. Point your CLI at the router

   Set the base URL and the key from the dashboard in Claude Code, Codex, Cursor, Cline or OpenClaw, then pick a model.

```text
Endpoint: http://localhost:20128/v1
API Key:  [copy from dashboard]
Model:    kr/claude-sonnet-4.5
```

4. Or run it from source

   Source and Docker are the expected local development paths.

```bash
cp .env.example .env
npm install
PORT=20128 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run dev
```

5. Production mode

   Dashboard at /dashboard, OpenAI-compatible API at /v1.

```bash
npm run build
PORT=20128 HOSTNAME=0.0.0.0 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run start
```

## When to use it

- Keep a coding agent running past a provider rate limit by falling back automatically instead of stopping
- Spend a monthly subscription quota fully before it resets, then move to cheaper models
- Cut agent token spend by compressing the tool output that dominates the context window
- Drive several coding CLIs through one endpoint and one key rather than configuring each separately
