[KongchangAI]
· 3 min read· 1,953 words

9router: Aggregate All Free LLM APIs with a Single Router

9router: Aggregate All Free LLM APIs with a Single Router

9router uses a unified endpoint, three-tier fallback, and token compression to solve frequent API quota exhaustion in multi-Agent scenarios.

The article starts from the real pain point of API quota management in multi-agent collaborative development, showing measured data from 39 morning requests consuming about 1.9 million input tokens, costing about $0.02, with an input-to-output ratio as high as 81:1, pointing out that the bulk of the cost is in input tokens. It then introduces the open-source project 9router: built on Next.js, MIT-licensed, supporting 60+ providers and 100+ models, using a local Endpoint for central scheduling to achieve three-tier automatic fallback (subscription → low-cost → free), multi-account rotation, quota tracking, and OpenAI/Claude/Gemini format conversion. The article also highlights RTK Token Saver (saves 20%~40% input) and Caveman Mode (saves up to 65% output), as well as the Base URL configuration for connecting various Agents. Finally, it compares the heavier OmniRoute and reminds readers about free limits, ToS gray areas, and Dashboard security risks.

Title

9router: Aggregate All Free LLM APIs with a Single Router

Meta Description

9router is an open-source API routing tool supporting 60+ providers and 100+ models. With automatic fallback, multi-account rotation, and RTK token compression, it helps developers aggregate free LLM API quotas and avoid workflow interruptions from constantly switching keys.

Article Content

Multi-agent collaborative development is becoming the norm, but what really blocks developers isn't model capability—it's API quota management. When you're simultaneously using PiG, KiloCode, Claude Code, or Cline, each Agent needs to connect to several providers behind the scenes—GLM, Gemini, Groq, OpenCode. Each provider has its own API Key, and each free tier has daily, monthly, and per-minute limits. When one quota runs out, your workflow grinds to a halt. You have to open the Dashboard, swap keys, swap models, restart. Someone described this state as: "I feel like I'm doing ops, not development."

9router project source screenshot

A Morning That Revealed the Real Cost

A developer ran 39 requests through PiG before the morning was over and recorded this data:

MetricValue
Requests39
Input Tokens1,893,302
Cached Tokens1,269,568 (67% hit rate)
Output Tokens23,259
Estimated Cost~$0.02

The input-to-output ratio is nearly 81:1. The Agent reads a large number of skill files, AGENTS.md, the brain/ directory, and project files, but only produces about 23k tokens of actual output. The bulk of the cost is in input, not output. On average, each request has about 48,000 tokens of input. Without caching, the entire context has to be resent every round—which explains why free provider quotas burn out in minutes.

If 39 requests already look like this, in a scenario with 300 requests per day, paid provider bills would climb rapidly, and free providers would be exhausted before the afternoon. Compressing input and automatically switching providers have become the two key levers for sustaining daily development.

About Cached Tokens: Major LLM APIs (Anthropic Claude, OpenAI, Gemini, etc.) support Prompt Caching. When the context prefix of a request is exactly the same as the previous request, the provider bills that portion at the cache price, typically only 10%~25% of the normal input price. This explains why in the table above, 1,269,568 tokens are billed at the cache price, while the remaining ~620k tokens are billed at full price—the gap between the two is the bulk of the cost. To get cache hits, you must keep the context prefix stable: fixed content such as skill files, AGENTS.md, and the brain/ directory should be placed at the front of the Prompt, while dynamic content (user messages, tool results) goes at the back.

Why the input-to-output ratio is nearly 81:1: The essential difference between an Agent and traditional Chat is that an Agent must resend its complete working memory (skill instructions, historical tool calls, file contents, thought traces) to the model every round, while the actual generated response is often only a few hundred words. This "long input, short output" pattern makes the token bill almost entirely determined by input, and also makes input-side compression tools like RTK far more valuable than output-side optimization.

How 9router Solves Multi-Provider Management

9router (decolua/9router) is an MIT-licensed open-source project built on Next.js. Installation takes just two commands:

npm install -g 9router
9router

The Dashboard opens automatically at http://localhost:20128, supports 60+ providers and 100+ models, and also has a Docker version available.

The core idea is: Agents don't connect directly to each provider, but point uniformly to a local Endpoint. 9router handles scheduling in the middle, responsible for automatic fallback, quota statistics, token compression, and API format conversion. From the Agent's perspective, it's just talking to an OpenAI-compatible Endpoint.

Three-Tier Automatic Fallback Mechanism

9router arranges providers by priority:

  1. Tier 1 — Subscriptions (if available): Claude Code, Codex, Copilot
  2. Tier 2 — Low-cost: GLM, MiniMax, Kimi, just a few cents per million tokens
  3. Tier 3 — Free: Kiro, OpenCode Free, Vertex, NVIDIA NIM

When one tier's quota runs out, it automatically jumps to the next tier—no need to get up in the middle of the night to change configs.

About OpenAI-compatible Endpoints: The "OpenAI-compatible Endpoint" repeatedly mentioned in this article refers to an HTTP service that follows the OpenAI Chat Completions API specification (i.e., POST /v1/chat/completions, with a request body containing fields like model, messages, stream, and a response returning choices[].message.content). Almost all current Agent tools (Cline, Continue, Aider, PiG) and SDKs use this format as their default protocol, while Anthropic's Messages API and Google's Gemini API each have different Schemas (such as /v1/messages, /v1beta/models.generateContent).

9router's "format conversion" feature is essentially a protocol adaptation layer: it exposes a unified OpenAI Schema to upstream Agents, while translating requests and responses to downstream providers according to their native protocols (Anthropic, Gemini, Vertex, etc.), including mapping of system prompt positions, tool call structures, and streaming chunk formats. This is also the technical prerequisite that makes "any tool connects to any provider" possible—otherwise tools like Claude Code that only recognize the Anthropic format couldn't connect to GLM or Groq at all.

Free Providers You Can Connect

ProviderAccess MethodNotes
OpenCode FreeNo authentication requiredModel list changes over time
Kiro AIOAuthAbout 50 credits per month (Claude 4.5, GLM-5, MiniMax)
Vertex AIOAuthNew GCP accounts get $300 credit
NVIDIA NIMAPI KeyHas limits but practical
Cloudflare Workers AIAPI KeyFree quota is limited

These free providers all have limits, but through routing aggregation and automatic fallback, the overall capacity can still support daily development.

RTK and Caveman: Making Free Quotas Last Longer

Two token-saving features are worth noting:

  • RTK Token Saver: Compresses tool output (git diff, grep, ls, logs) before it reaches the model, saving 20%~40% of input tokens per request
  • Caveman Mode: Compresses model output, saving up to about 65%

For Agents that read a lot of files and execute commands, the difference these two features make is very noticeable.

About the difference in where RTK and Caveman work: RTK Token Saver acts before tool call results enter the model context, belonging to "input compression"—typical techniques include: keeping only the changed blocks and removing context lines from git diff, deduplicating and summarizing ls/grep/logs, and truncating or indexing overly long files as needed. It doesn't change the semantic content the model itself sees, but it can significantly reduce the tokens consumed by highly redundant text.

Caveman Mode acts on model output, compressing generated content through prompt constraints (requiring the model to use minimal phrases, omit articles and conjunctions, and remove pleasantries and explanatory prefixes/suffixes), saving up to 65%. What it sacrifices is output readability, so it's more suitable for scenarios where "the model only makes decisions and the results are consumed by code," such as outputting JSON, shell commands, or structured instructions. When the two are stacked, both the input side and output side slim down simultaneously, delivering the most direct benefit to developers with tight free quotas.

Other Practical Features

  • Multi-account: Register multiple accounts for the same provider and rotate usage
  • Combiner: Chain multiple providers into one virtual provider
  • Quota tracking: View balances and reset times in real time
  • Format conversion: Convert between OpenAI, Claude, and Gemini formats—any tool connects to any provider

How to Connect Agents

Just point the Base URL to the router in your tool settings, use auto as the model name, and the router will automatically select an available provider and handle failover. You can also specify a concrete model like kr/claude-sonnet-4.5.

# Tools compatible with OpenAI (PiG, Cline, Continue, etc.)
OPENAI_BASE_URL=http://localhost:20128/v1
OPENAI_API_KEY=sk-xxxxxxxx

# Tools compatible with Anthropic (Claude Code, etc.)
ANTHROPIC_BASE_URL=http://localhost:20128
ANTHROPIC_AUTH_TOKEN=sk-xxxxxxxx

For the Agent, nothing changes—it still feels like it's talking to an ordinary Endpoint. What changes is this: when some provider hits its ceiling, the work interruption disappears.

OmniRoute: A Heavier Alternative

If you need more, there's also OmniRoute (diegosouzapw/OmniRoute), with essentially the same goals—provider hub, automatic fallback, token savings, the same localhost:20128 endpoint. The difference is that it's a heavier superset:

  • 350+ providers instead of 60+
  • Built-in memory, MCP Server, semantic cache, A2A
  • Encrypted credential storage

For an ordinary homelab machine, 9router is already enough. OmniRoute suits scenarios where you want "everything on" and don't mind the weight.

About MCP, A2A, and Semantic Cache:

  • MCP (Model Context Protocol): An open protocol proposed by Anthropic in 2024 that lets models access external tools, data sources, and resources (file systems, databases, GitHub, etc.) in a unified way. An MCP Server is the server-side service that exposes these capabilities to Agents, replacing proprietary Function Calling formats from various vendors.
  • A2A (Agent-to-Agent): A protocol led by Google for different Agents to discover each other, delegate tasks, and exchange context—the standard communication layer for multi-agent collaboration.
  • Semantic Cache: Unlike traditional caching that exactly matches Prompt strings, semantic caching uses Embedding to compute similarity and directly returns hits for historically "similar in meaning" requests. Hit rates are higher but there's a risk of semantic drift, usually requiring a similarity threshold to be set.

None of these three are built into 9router, which is the main reason OmniRoute is positioned as a "superset"—and also corresponds to heavier resource usage and maintenance complexity.

Risks to Watch Out For

A few honest reminders from the original article:

  • "Free" usually has limits. Don't expect unlimited throughput. The Router only helps you aggregate providers and fall back when limits are hit.
  • Some providers are in a gray area. Accessing your own OAuth subscriptions through third-party proxies violates the ToS of vendors like Anthropic and Google, and there have been reports of accounts being banned. If you want to try, don't use important accounts.
  • The Dashboard holds all your API Keys. Don't expose the port to the public internet, and set a strong password.

For personal projects, learning, and homelabs, this solution is safe and extremely cost-saving.

What Actually Changes

For developers who can't afford monthly token expenses, what 9router changes is the work rhythm. Previously, quota exhaustion forced you to stop mid-coding; now you just point your Agent at one URL and work continues.

It's not magic—the limitations of free providers still exist. But as a hub that aggregates free resources in one place with automatic fallback, it's currently one of the most cost-effective options. If you use multiple Agents simultaneously and often hit "rate limit exceeded," it's worth a try.

One-line Summary

9router solves the pain of rapidly exhausting API quotas in multi-Agent scenarios through a unified endpoint, three-tier fallback, and token compression.

Paragraph Summary

The article starts from the real pain point of API quota management in multi-agent collaborative development, showing measured data from 39 morning requests consuming about 1.9 million input tokens, costing about $0.02, with an input-to-output ratio as high as 81:1, pointing out that the bulk of the cost is in input tokens. It then introduces the open-source project 9router: built on Next.js, MIT-licensed, supporting 60+ providers and 100+ models, using a local Endpoint for central scheduling to achieve three-tier automatic fallback (subscription → low-cost → free), multi-account rotation, quota tracking, and OpenAI/Claude/Gemini format conversion. The article also highlights RTK Token Saver (saves 20%~40% input) and Caveman Mode (saves up to 65% output), as well as the Base URL configuration for connecting various Agents. Finally, it compares the heavier OmniRoute and reminds readers about free limits, ToS gray areas, and Dashboard security risks.

#9router#API routing#free LLM API#API quota management#token compression
Share:

Related articles