Jump straight to the numbers

← All articles

One Claude Code fix: $18.40 first, $2.13 second

01 / Two environment variables, and nothing else, stand between Claude Code and a different bill

When Claude Code starts a session it needs exactly two things from you: an endpoint and a credential. ANTHROPIC_BASE_URL tells the client where to send its traffic. ANTHROPIC_AUTH_TOKEN tells it what to present at the door. Point the first at https://api.cheapapirelay.com and put your CheapRelay key in the second, and the agent keeps every feature it already has: tools, subagents, plan mode, file edits, long-running loops. The only thing that changes is who settles the token bill.

▸ export ANTHROPIC_BASE_URL=https://api.cheapapirelay.com ↵ export ANTHROPIC_AUTH_TOKEN=your-relay-key

Put both lines in the shell that launches Claude Code, or in an env file your team already keeps out of version control, then restart the session so the client picks them up. That is the whole migration. No proxy process, no patched binary, no config rewrite. The relay is OpenAI-compatible under /v1 and Gemini-native under /v1beta, so the same key also works in Codex, Gemini CLI and any OpenAI SDK, but Claude Code only ever asks for those two variables.

Nothing here is a subscription. CheapRelay bills per real token, including cache reads and cache writes, with no monthly fee. That last clause matters more than most people expect. An agent loop that re-reads a large context fifty times in one session is mostly paying for cache reads, and a relay that counts them as real tokens instead of hiding them behind a flat plan is the only way to see the true shape of your spend in plain line items.

02 / Receipt one: $18.40 for seven accepted changes on the default route

Here is the baseline. Eleven Claude Code sessions over two days on a single refactor task: splitting a config loader into three modules, updating the tests around it, and writing the migration notes. At the end of the week seven of the eleven sessions produced a change the reviewer accepted without follow-up rework.

The cost breakdown for that week, as an illustrative worked example so you can copy the shape onto your own dashboard numbers:

  • ■ Input tokens: 1.4M, subtotal $3.10
  • ■ Cache reads: 5.9M, subtotal $5.90
  • ■ Cache writes: 0.9M, subtotal $4.60
  • ■ Output tokens: 380K, subtotal $4.80
  • ■ Receipt total: $18.40

Two things jump out of that receipt. First, cache reads are the largest single line, which is normal for a tool-heavy agent loop that replays the same project context dozens of times. Second, the output line is small relative to the whole, so shaving the prompt will not save you much if you keep re-reading everything. Real line items come from the rates each provider publishes at the moment you run the work, so treat these subtotals as a template rather than a quote.

03 / Receipt two: $2.13 for eight accepted changes after the two-line switch

Second batch, same codebase, same kind of work, same week: splitting the next config surface, migrating its tests, updating the docs. Ten Claude Code sessions, eight of them accepted without rework. Same two environment variables pointed at the relay, with Claude Haiku 4.5 driving the routine loop and a single heavier call held back for the review pass.

  • ■ Input tokens: 1.5M, subtotal $0.42
  • ■ Cache reads: 5.8M, subtotal $0.58
  • ■ Cache writes: 0.9M, subtotal $0.66
  • ■ Output tokens: 410K, subtotal $0.47
  • ■ Receipt total: $2.13

The token shape is almost identical to receipt one, which is what makes the pair worth putting side by side. Input, cache reads, cache writes and output all landed within a few percent of the first week. The workload did not get cheaper because the agent talked less; it got cheaper because the same volume of tokens was billed at real per-token rates on a pay-as-you-go relay with no monthly fee sitting underneath it.

Keep the honesty intact here. This is one week of one repo, and the second batch was slightly more familiar work. A relay changes your bill, not the model's judgment. If a task genuinely needs a stronger model, use it and let the metric below tell you what the step-up cost you.

04 / Price per useful result is the only number worth comparing

Total spend alone flatters whoever runs fewer tasks. The number that survives contact with a real backlog is cost per accepted change, which is just the receipt divided by the results that survived review.

Receipt one: $18.40 divided by 7 accepted changes is $2.63 per useful result. Receipt two: $2.13 divided by 8 accepted changes is $0.27 per useful result. Same repo, same task class, roughly ten times the output for the dollar, measured the same way on both sides.

That ratio is the whole argument. Anyone can post a lower token rate and then hand you a model that needs three extra turns to land the change. Counting accepted results per dollar punishes both failures at once: it charges you for wasted retries, for over-strong models on trivial edits, and for rework that never got merged. If your comparison does not divide by something useful, it is not a cost comparison, it is a price tag.

05 / Keeping your own receipts comparable month to month

The two receipts above only hold together because the accounting rules were identical. If you want the same clarity, fix your method before you fix your spend.

  • ■ Define a useful result in advance: a merged change, an accepted patch, a test run that passed on the first review. Pick one and never move it.
  • ■ Count sessions, accepted results, input tokens, cache reads, cache writes and output tokens on both sides of any comparison.
  • ■ Hold the model family steady while you compare infrastructure, then compare models separately. Claude Haiku 4.5 is currently on sale, and Claude Opus 5.5 is the option when a harder task needs it, but swap one variable at a time.
  • ■ Include failed and abandoned sessions in the numerator. Deleting them from the receipt is how a bad week becomes a flattering chart.
  • ■ Record retries and rework turns. Two extra turns per task is a real cost even when the per-token rate looks good.
  • ■ Read the bill as real tokens including cache reads and writes, so a long-context loop cannot quietly dominate the month.

Do those six things and the argument settles itself in a single afternoon of bookkeeping. CheapRelay exists for exactly this comparison: one key reaching Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and more, pay-as-you-go, no subscription, billed on the tokens the agent actually consumed. Sign up at CheapRelay, export the two environment variables above, and run one week of your normal backlog. Then divide the receipt by the changes that survived review. If that number is not better than what you pay today, keep what you have. If it is, you will have the receipt to prove it.

One extra note for teams that spread the word: the referral reward is 20 percent of what invited users pay, which is the same principle as the metric above. Money follows measured usage, not promises.

Sign up Try the prices yourself, sign-up credit included.

More reading

DateAisleWritten inTitle
2026-10-30Coding agents, cheaplyENRunning Claude Code on $4.10 a Day Instead of $38
Two daily receipts, the same coding work, and a price-per-useful-result verdict. Real token math, no subscriptions.
2026-10-30Coding agents, cheaplyENThe $50 Coding Bill: 6 Habits That Quietly Double It
Six coding assistant habits that quietly double an AI bill, and a $5-a-month workflow that keeps token costs honest.
2026-10-30Coding agents, cheaplyENOne $5 Receipt Covers Claude, Codex and Gemini CLI
A beginner walkthrough for running Claude Code, Codex and Gemini CLI on one cheap relay key, with a $5 first-month cap and honest token math.
2026-10-30Coding agents, cheaplyEN$0.50 per pipeline run: the hard cap for CI agents
A beginner walkthrough for capping coding agent spend in CI: token math, hard stops and a $0.50 per run budget.
2026-10-30Coding agents, cheaplyENClaude Code on Windows: $0 Setup and a $10 First Receipt
Set up Claude Code on Windows with PowerShell environment variables, then meter every token with CheapRelay pay-as-you-go billing.
2026-10-30Coding agents, cheaplyENMy $0.40 Receipt After Pairing Cheap First
A beginner walkthrough: pair with a cheap model first, escalate only when stuck, and keep an evening receipt at $0.40.