Guide
Claude Code Router: How to Route Requests by Model
If you searched for a Claude Code router, you probably want one of two things: send different kinds of requests to different models, or keep Claude Code running without paying proprietary rates for every token. Both are doable, and the setup is simpler than most guides make it sound.
Below, we'll cover what a router does in a Claude Code workflow, which routing strategies hold up in practice, how to configure them, and where a managed option like dl.new fits if you'd rather skip the plumbing.
Full disclosure: we make dl.new.
What a Claude Code router actually does
Claude Code is a terminal-based coding agent. Out of the box, it talks to one model from one provider. A router sits between the tool and the model backends and decides where each request goes.
Think of it as a switchboard. Claude Code sends a request in the format it already understands. The router reads it, applies your rules, and forwards it to the model you picked for that kind of work. The response comes back in the shape Claude Code expects, so the tool never knows anything changed.
That indirection is the whole point: you can swap the model without touching your workflow.
Why route by model at all
One model for everything is simple, but it's rarely the cheapest option or the best fit. A coding session is a mix of very different jobs:
- Quick, repetitive calls: file summaries, small edits, commit messages, renames. None of this needs your strongest model.
- Heavy reasoning: planning a refactor, chasing down a race condition, deciding where a module boundary belongs. A more capable model earns its cost here.
- Long-context reads: pulling a big chunk of a codebase into context to answer a question.
- Background tasks: cheap, high-volume work that runs constantly while you code.
Send all of that to one premium model and you pay premium rates for the easy 80 percent. Routing matches the model to the job.
Common routing strategies
Route by task type
The most useful split is between "think" and "do." Planning and architecture requests go to a stronger reasoning model. Routine edits and tool calls go to something faster and cheaper. Most router setups let you name a default model, a background model, a reasoning model, and a long-context model, then give each one a role.
Route by context size
Some models handle long inputs better, or charge less for them. A rule like "if the prompt exceeds a certain token count, use the long-context model" keeps a small-window model from choking on a large repo.
Route by cost ceiling
If you want predictable spend, make an inexpensive open-weight model your default and escalate to a more capable one only when you ask. It flips the usual habit of defaulting to the priciest option and hoping the bill stays reasonable.
Route by provider availability
Providers go down and hit rate limits. A router with fallback rules can retry on a second provider when the first one fails, so your session doesn't stall mid-task.
How to set up routing for Claude Code
The exact steps depend on which router you use, but the shape is the same across tools.
- Run the router locally or point to a hosted one. Most self-hosted options start a small local server that speaks the same API format Claude Code uses.
- Point Claude Code at the router. Set the base URL and an auth token through environment variables, so Claude Code sends requests to the router instead of straight to a provider.
- Define your providers and models. Add the API keys and model names for each backend you want available.
- Write the rules. Assign a default model, then add conditions for background work, reasoning, and long context.
- Test with a real task. Run a small edit and a bigger planning request, then check the router's logs to confirm each one went where you expected.
A few habits save time. Keep your rules short and readable. Start with just two models and add more once the split proves useful. And log every request for the first week, so you see what the router is actually doing rather than what you assumed it would do.
What to watch out for
Self-managed routing is flexible, but it comes with real maintenance.
- Format mismatches. Providers handle tool calls and streaming a little differently. A model that works fine in a chat window can behave oddly inside an agent loop that depends on precise tool-call formatting.
- Key sprawl. Every provider you add means another account, another API key, and another bill to track.
- Inconsistent quality. A cheap model that handles small edits well may stumble on multi-file changes. Route conservatively until you've seen it perform.
- Silent failures. If a fallback rule fires and you don't notice, you may be running on a model you never meant to use.
None of these are dealbreakers. They're the price of owning the setup yourself.
Open-weight models as the routing target
Routing gets much more appealing when the models you route to are open-weight. They're available from multiple providers, which means price competition and more options when one backend is slow or down. They've also become capable enough to cover a large share of everyday coding work.
That changes the math. Routing no longer has to be a rare cost-cutting trick. You can make an open-weight model your default and treat a proprietary model as the exception you reach for on purpose.
A managed alternative: dl.new
If you like what routing gives you but not the upkeep, dl.new handles it. It's a subscription that lets you run AI coding tools like Claude Code, Grok Build (formerly Cursor), and Cline on open-weight models instead of pricier proprietary ones.
The workflow is short. After you subscribe, you install a CLI with one command and launch your tool through it. dl routes your requests to models across multiple providers, so you aren't juggling accounts, keys, and config files yourself.
Billing works differently too. Instead of per-token pricing, plans come with weekly token allowances, so cost is predictable rather than something you check nervously at the end of the month.
Here are the current plans:
| Plan | Price | Weekly allowance |
|---|---|---|
| Free | $0, no card | 10M DeepSeek V4.1 Flash tokens |
| Starter | $7/mo | ~62M DeepSeek V4.1 Flash tokens |
| Plus | $20/mo | ~300M DeepSeek V4.1 Flash and ~1.5M Kimi K3.1 tokens |
| Max | $60/mo | ~1B DeepSeek V4.1 Flash and ~4M Kimi K3.1 tokens |
The free plan is 10M tokens/week of DeepSeek V4.1 Flash, DeepSeek only, no card. All allowances have 95.5% caching applied. Each model has a hard weekly limit, and when you reach your Kimi limit, requests fall back to DeepSeek automatically rather than stopping your session. We never charge overage.
It's a good fit when you want open-weight models behind Claude Code without building and maintaining your own routing layer. If you need very custom rules, like routing by file path or a bespoke cost policy, a self-hosted router still gives you finer control.
Choosing between a DIY router and a managed one
A quick way to decide:
- Build your own router if you want granular rules, enjoy tuning your setup, or need to mix in private or self-hosted models.
- Use a managed option if you mainly want Claude Code on cheaper open-weight models, with minimal setup and a flat, predictable allowance.
Plenty of developers end up in the second group once they price out the time spent maintaining the first.
FAQs
What is a Claude Code router?
It's a layer between Claude Code and one or more model providers. It receives each request, applies your rules, and forwards it to the model you assigned for that kind of task. The response comes back in a format Claude Code understands.
Can Claude Code use models other than Claude?
Yes. Claude Code talks to an API endpoint, so you can point it at a router that forwards requests to other models, including open-weight ones. The router translates between formats, and the tool keeps working as usual.
How do I route different tasks to different models?
Define roles in your router configuration: a default model, a background model, a reasoning model, and a long-context model. Then assign each role to the model that suits it. Planning and architecture go to the stronger model, and routine edits go to a cheaper one.
Will routing to cheaper models hurt code quality?
It can if you route carelessly. Cheaper models often handle small, well-scoped edits fine but struggle with multi-file changes or subtle debugging. Start conservatively, watch the results, and give the cheap model more responsibility only as it earns your trust.
Do I need to manage separate API keys for each provider?
With a self-hosted router, yes. Each provider needs its own account and key. A managed service like dl.new removes that burden by routing across providers for you under a single subscription.
How does dl.new differ from running my own router?
dl.new gives you a one-command CLI install and handles routing to open-weight models across multiple providers. You pay a subscription with weekly token allowances instead of per-token billing. A self-hosted router offers more custom rules, but you have to maintain it.
What happens if I use up my weekly allowance on dl.new?
Each model has a hard weekly limit, and hitting one doesn't stop your work: when you reach your Kimi limit, requests fall back to DeepSeek automatically. Your allowances reset every week, and we never charge overage.
Conclusion
A Claude Code router lets you stop treating every request as equal. Send planning to a strong model, routine work to a cheap one, and set fallbacks so outages don't stop you. Start with two models and a handful of rules, check the logs, and adjust from there.
If you want that result without the setup and upkeep, create your dl key and run Claude Code on open-weight models through a single CLI.