I switched how Claude Code reaches its models and my bill dropped by more than half. Nothing about my code changed — two environment variables did it.
This is the single highest-leverage change I know of for anyone running Claude Code against a paid API, and it takes about a minute.
The problem: Claude Code re-sends your whole project every turn
Every turn of a Claude Code session re-reads your working context. For a mid-sized repo that is 30k–50k input tokens of mostly-identical content, billed again and again.
Anthropic's prompt cache exists precisely for this: identical prefixes get billed at a much lower rate. The catch is that the cache is protocol-specific. It is a feature of the Anthropic-native /v1/messages endpoint.
Why the OpenAI-compatible route quietly costs more
A lot of gateways advertise "OpenAI-compatible" as their headline feature, and it is genuinely convenient — one client, every model. But if you point Claude at an OpenAI-shaped endpoint, you are on the wrong protocol:
- Prompt cache does not carry through. Those 30k–50k tokens bill at full input rate on every request instead of the cached rate.
- Thinking is lost too, which degrades output on anything non-trivial.
The result is a setup that works perfectly, feels fast, and costs roughly double what it should. This is the mistake I made for a month before reading the pricing docs properly.
The two env vars
Point Claude Code at the Anthropic-native endpoint:
export ANTHROPIC_BASE_URL="https://api.teamorouter.com" export ANTHROPIC_API_KEY="sk-teamo-xxxxxxxx" Then hit /v1/messages — not /v1/chat/completions.
For Codex, or anything OpenAI-shaped, stay on the OpenAI protocol and only swap the base URL:
export OPENAI_BASE_URL="https://api.teamorouter.com/v1" export OPENAI_API_KEY="sk-teamo-xxxxxxxx" No SDK changes. No client rewrites.
How to verify the cache is actually hitting
Do not trust the vibe — check the numbers. In the API response, look at the usage block:
{ "usage": { "input_tokens": 41230, "cache_read_input_tokens": 40188, "cache_creation_input_tokens": 1042, "output_tokens": 312 } } cache_read_input_tokens should be a large fraction of input_tokens on every turn after the first. If it stays at zero, you are on the wrong protocol and paying full price.
One more auth detail that causes confusion: Anthropic-native expects x-api-key, OpenAI expects Authorization: Bearer. If you are getting 401s, that is almost always why.
What to check before you pick a gateway
- Do they expose the Anthropic-native endpoint at all? If it is only "OpenAI-compatible", skip it — you are choosing the expensive path.
- Is there a cache-read column in the pricing table? For agent workloads that column decides your bill, not the input column.
- Do credits expire? Is a subscription required? Pay-as-you-go with no expiry is the baseline.
- Is the discount per-model and live, or a static "huge savings" banner?
- Is uptime published per model, or one global number that hides the model you actually use?
What I landed on, for reference: TeamoRouter — Anthropic-native plus OpenAI-compatible plus Responses API plus Gemini native, live per-model pricing with input/output/cache columns, credits that do not expire, no subscription, per-model SLA published as a range.
Two caveats worth stating plainly: pricing is USD-denominated, so you carry FX exposure if you budget in another currency; and entity/registration details are not collected in one place on the site, so ask before a corporate purchase.
Disclosure: this post includes affiliate links; I may receive compensation if you purchase products or services from the links provided in this article.
