How I Cut My Claude API Bill by ~70% Without Changing My Code
My Claude API bill used to be the line item I avoided looking at. Not because any single call was expensive — a few cents here, a few cents there — but because a coding agent session quietly burns through tokens the way a long drive burns through fuel. You don't notice it until the invoice arrives.
The fix turned out to be embarrassingly simple. I didn't change my prompts, switch models, or write less code. I changed one line: the base URL my API client talks to. Here's what that means, what it actually saved, and the habits that cut the bill further.
Why the bill is bigger than you think
API pricing looks cheap until you do the arithmetic. Output tokens cost roughly five times as much as input tokens, and a coding agent is an output machine: every plan it writes, every file it rewrites, every explanation it gives is output.
Take a typical heavy session with Claude's Fable 5.2 model — 100,000 input tokens and 20,000 output tokens. At the official list price of $8 per million input tokens and $40 per million output tokens, that's:
- Input: 100,000 × $8 / 1,000,000 = $0.80
- Output: 20,000 × $40 / 1,000,000 = $0.80
- Total: $1.60 per session
One session is nothing. Thirty sessions a month is $48. Run a few agents in parallel, add a side project or two, and you're past $150 a month — for the exact same model, doing the exact same work.
What a relay is (and what it isn't)
An API relay is a middleman endpoint that speaks the same protocols as the official APIs — OpenAI-compatible and Anthropic-compatible — and forwards your requests to the real models. Your code doesn't change. Your prompts don't change. The model on the other end doesn't change. Only the address your requests go to changes, and the per-token price attached to it.
This is not a different model, a distilled copy, or a free tier with hidden limits. It's the same model ID, reached through a different door, at a different price. That's the whole trick — and it's why the switch is one line of code instead of a migration project.
The one-line switch
If you're using the OpenAI Python SDK, the change is the base_url:
from openai import OpenAI
client = OpenAI(
base_url="https://key.zhuan.xyz/v1",
api_key="sk-your-zhuan-key",
)
response = client.chat.completions.create(
model="claude-fable-5-2",
messages=[{"role": "user", "content": "Refactor this function for readability."}],
)
print(response.choices[0].message.content)
Using the Anthropic SDK, it's the same idea:
import anthropic
client = anthropic.Anthropic(
base_url="https://key.zhuan.xyz/v1",
api_key="sk-your-zhuan-key",
)
message = client.messages.create(
model="claude-fable-5-2",
max_tokens=1024,
messages=[{"role": "user", "content": "Refactor this function for readability."}],
)
print(message.content[0].text)
Or raw cURL, if you want to see exactly what's happening:
curl https://key.zhuan.xyz/v1/chat/completions \
-H "Authorization: Bearer sk-your-zhuan-key" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5-2",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Everything else — your retry logic, your streaming code, your tool-use loop — stays exactly as it was. If the relay ever misbehaves, you change the base URL back and you're on the official API again in seconds. That reversibility is the reason this is a safe experiment rather than a commitment.
The worked example: what it actually saved
Here's the same workload, priced both ways, using the live figures from zhuan.xyz/pricing (synced 2026-11-17). Say you run 10 million input tokens and 2 million output tokens a month on Fable 5.2:
| Official price | zhuan.xyz | Saving | |
|---|---|---|---|
| Input (10M tokens) | $80.00 | $24.82 | −69% |
| Output (2M tokens) | $80.00 | $24.84 | −69% |
| Monthly total | $160.00 | $49.66 | ~$110 saved |
And the same comparison across a few other models, per million tokens:
| Model | Official (in / out) | zhuan.xyz (in / out) | Saving |
|---|---|---|---|
| Claude Fable 5.2 | $8 / $40 | $2.48 / $12.42 | −69% |
| Claude Sonnet 5.5 | $2 / $10 | $0.59 / $2.96 | −70.4% |
| Claude Opus 5.5 | $4 / $20 | $1.18 / $5.92 | −70.4% |
| GPT-6.1 Sol | $2 / $10 | $0.24 / $1.19 | −88.1% |
Prices change — relay pricing syncs daily — so check the pricing page on the day you switch rather than trusting any article, including this one.
Three habits that cut the bill further
A cheaper per-token price is the big win, but these three habits stack on top of it:
1. Cache what you repeat. System prompts, project context, and few-shot examples get sent again and again. Prompt caching makes repeat reads far cheaper than fresh input — on Fable 5.2, cache reads run about $0.06 per million tokens through the relay. If your client supports caching, turn it on; it's the closest thing to free tokens.
2. Right-size the model. Not every call needs the flagship. Drafts, summaries, and simple refactors run fine on a cheaper model like Sonnet or Haiku; save the heavy model for the hard reasoning. One key that reaches all the models makes this a one-word change (model="claude-sonnet-5-5") instead of a new account.
3. Cap the blast radius per key. This is the habit most people skip, and it's the one that prevents the horror-story bill. Use a separate API key per project, set a quota and rate limit on each one, and pause a key the moment a runaway loop starts. Itemised per-call billing — seeing exactly which key spent what, call by call — is what turns "the bill went up" into "the Friday-night batch job did it." If a provider can't show you per-call usage, that's a reason to be cautious, not a detail to ignore.
The honest caveats
A relay is a middleman, and middlemen deserve scrutiny. Before you route real work through any relay, check three things: that the model you asked for is the model you got (the response should carry the real model fingerprint), that latency and uptime hold up under your actual workload, and that billing is itemised per call so you can audit every cent. A relay that hides any of those is not saving you money — it's charging you in trust instead.
The switch itself, though, is genuinely low-risk: one line, fully reversible, same models, same code. I ran my own workload through it for a month before writing this, and the ~70% saving in the table above is the arithmetic on my actual usage pattern, not a marketing number.
If your API bill has been the line item you avoid looking at, try the one-line version. The worst case is you learn exactly what your usage costs — and that's useful information even if you switch straight back.
— Davis George · zhuan.xyz
Top comments (0)