CLI · TOOLING
Claude Code for $0? Use OmniRoute
OmniRoute is a gateway you run locally. It puts one endpoint in front of a lot of model providers, several of which are free and need no signup — and Claude Code takes its base URL from config, so you point it at the gateway instead of at Anthropic. That is where the $0 comes from: not a discount, a different model answering.
Every value below is from OmniRoute’s own README and
docs/guides/CLAUDE-CODE-CONFIGURATION.md. Where a write-up I found disagrees,
I say so and why it matters.
Prerequisites
node -v # 22.x, 24 LTS (recommended), 25.x or 26.x
claude --version # npm i -g @anthropic-ai/claude-code
1. Install and start
npm install -g omniroute
omniroute
| Dashboard | http://localhost:20128 |
| API endpoint | http://localhost:20128/v1 |
A fresh install has keyless providers already wired — OpenCode Free, Kilo Code,
Pollinations — so there is nothing to sign up for, and the pseudo-model auto
routes to whichever of them is available.
2. Create your gateway key
The gateway authenticates its own endpoint, so you need a key before Claude Code can talk to it.
Dashboard → Endpoints → generate. Copy it; it looks like oma_live_….
3. Configure Claude Code
Add this to ~/.claude/settings.json. Four lines, and none of them names a
model — auto is the default, and on a keyless install that is the whole point:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:20128",
"ANTHROPIC_AUTH_TOKEN": "oma_live_xxx",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
}
}
The last line lets Claude Code list the gateway’s models in its own picker rather than Anthropic’s. Claude Code reads env once, at startup — restart it.
Pinning specific models, optionally
To bind Claude Code’s Opus/Sonnet/Haiku tiers to particular models, add three
more. Use IDs from a provider you actually have — the free ones are prefixed
oc/, and pasting a glm/ or kmc/ ID from a guide will fail with a 401
because those are paid providers you have not connected:
{
"env": {
"ANTHROPIC_DEFAULT_OPUS_MODEL": "oc/deepseek-v4-flash-free",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "oc/deepseek-v4-flash-free",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "oc/deepseek-v4-flash-free"
}
}
Model IDs move. Take the exact strings from your dashboard’s model list, not from here.
/v1 on the base URL
Claude Code appends /v1/messages itself, so the base URL is the gateway
root. At least one popular write-up shows http://localhost:20128/v1; that
resolves to /v1/v1/messages, the gateway 404s, and Claude Code silently
falls back to the real Anthropic API — it keeps working, and you keep paying.
OmniRoute’s own configuration guide says to omit the suffix.
4. Verify the endpoint
curl http://localhost:20128/v1/models \
-H "Authorization: Bearer oma_live_xxx"
A JSON list means the endpoint and the key are both good. It is also where you read the real model IDs for the optional block above.
5. Prove it is actually routing
That only proves the gateway is up. It does not prove Claude Code is using it, and the failure mode above is silent. Two checks that cannot lie:
- Run
/statusin Claude Code. The API base URL should readlocalhost:20128, notapi.anthropic.com. - Stop the gateway —
Ctrl-Cin theomnirouteterminal — and send a prompt. Claude Code should fail to connect. Start it again; the prompt works.
If step 2 answers normally with the gateway down, you are still on Anthropic’s API and still being billed.
If something breaks
| Symptom | Cause |
|---|---|
| Works, but still billed | /v1 left on the base URL, or Claude Code not restarted |
400 Ambiguous model |
Use a prefixed ID, e.g. cc/claude-opus-4-8 |
401 on a specific model |
That provider is not connected — pick one from /v1/models |
401 from the gateway |
Key missing or not the one from Dashboard → Endpoints |
| Connection refused | omniroute is not running, or something took port 20128 |
You are routing prompts — which for a coding tool means your source — through providers whose terms you have not read. Free tiers are often free because the traffic is worth something to somebody. Side projects and learning: fine. An employer’s codebase: check first.