Claude Code in Two Variables: Read the Receipt
01 / Two variables first, a token receipt second
A useful coding bill should read like a receipt: quantities, unit prices, line totals, and an amount you can reconcile. CheapRelay’s supplied service description promises per-token billing, including cache reads and writes, without a monthly fee or subscription. That makes the practical question straightforward: what did this particular coding session consume?
Below is a two-variable setup followed by a worked $0.38 receipt. The receipt is illustrative, not a measured session or a CheapRelay price quote. Live relay rates were not independently verified; substitute the rates shown for your selected model before making a spending decision.
02 / Point the terminal at CheapRelay with two exports
For an installed Claude Code CLI, use these two lines in Bash or Zsh, replacing the placeholder with your relay key:
export ANTHROPIC_BASE_URL="https://api.cheapapirelay.com"
export ANTHROPIC_AUTH_TOKEN="YOUR_CHEAPRELAY_KEY"
These are the gateway address and bearer credential variables documented for Claude Code. Run claude from that same terminal, then use /status to check the base URL and credential source. Shell exports apply to that terminal and programs launched from it, not automatically to every editor window. ([code.claude.com](https://code.claude.com/docs/en/llm-gateway-connect))
Use the root address above for this setup rather than automatically appending /v1. Claude Code requires a supported gateway API format; OpenAI compatibility alone does not establish that a particular endpoint supports its requests. Confirm CheapRelay’s current Claude Code instructions if the test fails. Anthropic documents supported-format compatibility as a gateway requirement. ([code.claude.com](https://code.claude.com/docs/en/llm-gateway))
Start with one small request, not an unattended repository-wide task. Check that it succeeds and that the relay records usage before relying on the configuration. Keep the real key out of screenshots, shared shell snippets, and version control.
03 / An illustrative $0.38 receipt with four billable lines
For arithmetic only, assume four USD rates per million tokens: $1.00 for uncached input, $5.00 for output, $1.25 for cache writes, and $0.10 for cache reads. These are hypothetical accounting inputs, not advertised relay rates or a claim about any model’s current price.
- ■ Uncached input: 120,000 tokens × $1.00 / 1,000,000 = $0.120.
- ■ Output: 30,000 tokens × $5.00 / 1,000,000 = $0.150.
- ■ Cache writes: 40,000 tokens × $1.25 / 1,000,000 = $0.050.
- ■ Cache reads: 600,000 tokens × $0.10 / 1,000,000 = $0.060.
- ■ Total: 790,000 accounted tokens; illustrative usage charge = $0.380.
The categories here are separate: uncached input excludes the tokens assigned to cache writes and reads. Adding those cache quantities to an input total that already includes them would double-count usage. Match your calculation to the categories actually reported by the relay.
Output contributes $0.15, approximately 39.5% of this example’s bill. Cache reads contribute $0.06 despite representing approximately 75.9% of its token quantity. Under these assumed rates, counting tokens without separating their prices would obscure the actual cost drivers.
04 / Turn the sample receipt into a spending rule
Twenty identical receipts would total $7.60; one hundred would total $38.00. Those are multiplication exercises, not monthly forecasts. They assume unchanged rates and identical quantities on every run.
Likewise, reducing only output by 25% removes 7,500 tokens from the example. At the assumed output rate, that saves $0.0375 and lowers the total to $0.3425. This is a sensitivity calculation, not evidence that shorter answers preserve coding quality.
For your own receipt, record the selected model, all applicable token rates, each usage category, and the final charge. Investigate discrepancies before scaling up. Treat any minimum funding amount, payment charge, or tax separately if one applies; none is assumed here.
05 / Make the first relay run an accounting check
Sign up for CheapRelay when you are ready to test a small, bounded coding task. Verify the current rates, configure the two variables, and compare the recorded usage with your calculation. The useful outcome is not a spectacularly cheap anecdote: it is a repeatable receipt you understand before authorizing more work.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-25 | Coding agents, cheaply | EN | Coding Assistant Habits That Double Your Bill A receipt-style breakdown shows how oversized prompts and verbose answers turn a $0.60 coding session into $1.20, before retries. |
| 2026-10-25 | Coding agents, cheaply | EN | Three AI CLIs, One Desktop, a $30 Budget A receipt-style plan for running Claude Code, Codex and Gemini CLI together, with a $30 usage budget and no invented token prices. |
| 2026-10-25 | Coding agents, cheaply | EN | Coding Agents in CI: A $0.50 Pipeline Budget Build a receipt for every coding-agent run, reserve spend before requests, and stop retries before they turn a small fix into a large bill. |
| 2026-10-25 | Coding agents, cheaply | EN | Claude Code on Windows: A PowerShell Cost Receipt Configure Claude Code with PowerShell environment variables, then audit a four-line token receipt without confusing example rates with real prices. |
| 2026-10-25 | Coding agents, cheaply | EN | Gemini CLI vs Claude Code: The Shell Chore Receipt A concrete token-cost comparison for shell chores, with itemized receipts, retry math, cache caveats, and practical spending controls. |
| 2026-10-25 | Coding agents, cheaply | EN | Cheap First, Escalate Later: A Coding Cost Receipt A worked token receipt shows how cheaper-first pair programming can cut API spending, with clear rules for escalating without wasting developer time. |