# 9router

> Local proxy that routes AI coding tools to subscription, cheap, or free models

- Repository: https://github.com/decolua/9router
- Category: Token & cost savings
- Stars: 31,245 · Forks: 6,028 · Language: JavaScript · License: MIT
- Experience: Some experience
- Page: https://ir.adyog.com/repos/decolua/9router/

AI coding tools like Claude Code, Codex, Cursor and Cline hit rate limits, burn through paid quota, and tie you to one provider. 9Router is a local server you point those tools at instead. It exposes an OpenAI-compatible endpoint at localhost:20128/v1 and forwards each request to a provider you have connected.

Behind that endpoint it translates between API formats (OpenAI and Claude), tracks quota, and refreshes tokens. You use tiers: subscription providers first, then cheap ones such as GLM or MiniMax, then free ones such as Kiro or OpenCode Free. When one tier runs dry, requests move to the next.

It also has a feature called RTK that compresses tool_result content, such as git diff, grep or ls output, before sending it on. The README claims 20-40% token savings. That is the author's figure, so test it on your own work. Free tiers have credit caps, so expect limits, not truly unlimited use.

## What it does

- **Automatic fallback tiers**: Moves from subscription to cheap to free providers when quota is exhausted, so a coding session keeps going.
- **RTK token saver**: Compresses tool_result content like git diff and grep output before it reaches the model, to reduce tokens per request.
- **One endpoint for many tools**: Gives Claude Code, Codex, Cursor, Cline, OpenClaw and others a single OpenAI-compatible URL and an API key from the dashboard.
- **Format translation**: Converts between OpenAI and Claude request formats so tools can use models from different vendors.
- **Multi-account and quota tracking**: Round-robins between several accounts per provider and tracks quota so you can use what you pay for before it resets.

## What you could build

- Point Claude Code or Codex at a local endpoint that falls back to free models when your quota runs out.
- Spread requests across several accounts of one provider to avoid rate limits.
- Cut token use on tool-heavy agent sessions by compressing command output.
- Try different providers and models from one tool without reconfiguring each time.
- Run a shared gateway on a server or in Docker for a small team.

## Who it's for

Developers who use AI coding CLIs or editors and want lower cost or fewer rate-limit stops; know how to set a custom API endpoint and key first.

## Get started

Install it globally with npm and run it, then open the dashboard at http://localhost:20128. Connect a free provider such as Kiro AI or OpenCode Free, then set your coding tool's endpoint to http://localhost:20128/v1 with the API key from the dashboard.

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

Tags: llm-gateway, token-saver, claude-code, openai-proxy, free-ai
