Tokipet/ Blog

Claude Code Router: Route to Cheaper Models (and Track What You Save)

By LMaoAGI · Updated 2026-05-28

Claude Code is great until the bill arrives. One of the most popular ways developers cut that bill is a router — a small proxy that sits between Claude Code and the model provider, so you can point it at cheaper or local models instead of paying frontier-model rates for every task.

This guide covers what Claude Code Router is, how to set it up (including routing through OpenRouter), the trade-off you're accepting, and how to actually measure whether it saved you money.

What is Claude Code Router?

Claude Code talks to a model through an Anthropic-compatible API endpoint. Claude Code Router (the widely used open-source one is musistudio/claude-code-router) is a local proxy that intercepts those calls and re-routes them — to OpenRouter, to another provider, or to a local model — based on rules you define.

The point is cost control: send simple edits to a cheap model, keep the expensive model only for hard work. Some people also use it to keep working when they've hit a subscription limit.

How to set up Claude Code Router

The exact config changes between versions, so treat this as the shape of the setup and confirm the specifics against the project's README.

  1. Install it. It ships as an npm package — install globally so it's available as a CLI.
  2. Add your providers. In its config file you list one or more providers (for example an OpenRouter API key) and the models each one exposes.
  3. Write routing rules. Map task types to models — e.g. a cheap model as the default, a stronger model for long-context or "think" tasks.
  4. Launch Claude Code through the router. The router points Claude Code's API base at itself, so Claude Code runs unchanged while every call flows through your rules.

Because it's a drop-in proxy, you keep using Claude Code exactly as before — same commands, same workflow — only the backend changes.

Using Claude Code with OpenRouter

OpenRouter is the most common backend people pair with the router, because one OpenRouter key unlocks dozens of models behind a single Anthropic-compatible endpoint. In practice you add OpenRouter as a provider in the router config, drop in your OpenRouter key, and map the model names you want Claude Code to use. From there you can route cheap tasks to a budget model and reserve a premium model for the rest — all without touching how you actually use Claude Code.

The trade-off: where your code goes

Routing isn't free of cost in another sense. When you send your prompts and code through OpenRouter or any third-party provider, that data leaves your machine and passes through their infrastructure — subject to their retention and privacy terms, not Anthropic's. For some teams that's a dealbreaker; for others it's an acceptable price for cheaper tokens. Worth deciding deliberately rather than by accident.

How much does routing actually save?

Here's the catch most router guides skip: people set up routing, feel cheaper, and never check. Without measuring, you don't know whether your rules actually shifted spend or just added a proxy hop — and a misconfigured router can route expensive tasks to the wrong model and cost you more.

The only way to know is to track real spend per model before and after. Tokipet does this locally: it reads your Claude Code session logs and shows cost broken down by model and by repo over time, so you can see your routing actually move the numbers. And unlike a third-party router, Tokipet is local-first — it only reads your logs on-device, nothing about your code leaves your machine. Set up routing to spend less; use Tokipet to prove it worked. (More on where Claude Code cost goes →)

FAQ

Can you use OpenRouter with Claude Code? Yes — through a router proxy like claude-code-router. You add OpenRouter as a provider, supply your key, and route Claude Code's calls to the models you choose.

Does Claude Code Router save money? It can, if you route routine tasks to cheaper models and keep premium models for hard work. Whether it actually does depends on your rules — measure your per-model spend to confirm.

Is it safe to route Claude Code through a third party? Functionally yes, but your prompts and code pass through that provider's servers under their privacy terms. If on-device privacy matters, weigh that before routing.


Routing is half the job — knowing it worked is the other half. Tokipet tracks your real Claude Code spend per model, locally, so you can see what your router actually saved you. Get Tokipet →

© Tokipet — your AI coding bill, as a living pixel pet. tokipet