2026-11-02 · 6 min read

Where Does a Claude Code Bill Actually Go?

Reading an AI API spend line by line: the three numbers on every request, the one mechanism that quietly dominates agent bills, and three questions that make any invoice auditable.

A monthly API bill is a terrible place to discover a question. It tells you what you spent, never where it went — and with agentic coding tools, where it goes is genuinely surprising the first time you look. This post is the mental model I wish every developer had before opening a billing dashboard.

Disclosure up front: I operate Teapot Router, an API gateway for Claude Code and OpenAI-SDK tools. Nothing here depends on it — the anatomy below applies to any Anthropic-compatible endpoint.

Every line is three numbers

A coding-agent request is billed on three components. Build the reflex: when a bill surprises you, don't ask which model is expensive — pull up lines and ask which of the three numbers moved.

  1. Prompt tokens — everything the model reads: system prompt, project context, the conversation so far, tool results. On a long session this is almost never "your question"; it's your question plus everything the agent re-read to answer it.
  2. Completion tokens — what the model writes back: code, reasoning, tool calls. Usually the minority of an agent bill.
  3. Cache reads/writes — prompt-cache pricing. Reads are steeply discounted hits; writes populate the cache. Whether your tool and endpoint cache well moves your effective rate dramatically.

The quiet dominant: context gets re-sent

Claude Code and similar agents are stateless at the wire: each turn, the client sends the conversation again — system prompt, file context, prior tool results included. Your 15th message in a session is billed as if you asked all 15 at once. That's not a flaw; it's how the protocol works. But it explains two counterintuitive facts:

A long cheap-model session can outcost a short expensive-model one. And the fix with the best ROI is usually managing context — clearing stale tool output, keeping sessions scoped, letting cache do its job — not hunting discounts.

Three levers, in order of honesty

Before touching a rate table, these are the levers ranked by how honestly they save money:

  1. Right-size the model per task. Boilerplate edits and greps don't need the flagship; the hard architectural asks do. Routing by task is the biggest honest saving.
  2. Make caching actually work. Prompt-cache reads are an order of magnitude cheaper than cold prompt tokens. Stable system prompts and session structure matter more than any rate table.
  3. Subscription vs. usage — do the arithmetic for your shape. Plans win if your usage is bursty-heavy on one model; usage-based wins the moment your workload is diverse, occasional, or shared across tools. There is no universal answer, only your own math.

Three questions to ask any provider

Whatever endpoint you use, these turn a black box into an audit trail:

  1. Can I see per-request cost, tokens, and latency — not just a monthly total? You should be able to export it.
  2. Is there a machine-readable price list, so scripts can compute cost before committing? A public no-login JSON endpoint is the bar I'd hold any provider to.
  3. What exactly happens to unused credit — expiry, refund policy, fees? "It just sits there forever" should be a written policy, not a vibe.

Privacy, since you're routing code through an endpoint

Ask what's retained. Teapot Router keeps billing metadata only — no prompt/response archiving — and you should verify rather than trust any vendor's "zero log" marketing, including ours.

You don't need to become a cost optimizer. You need your bill to be answerable: open the dashboard, find the line, name the number. Once your endpoint gives you that, every surprise becomes a one-line explanation instead of a support ticket.

FAQ

Why do long Claude Code sessions cost more per message?

Each turn re-sends the conversation so far, so message 15 is billed against a much larger prompt than message 1. Cost per message grows with session length even at a fixed price per token.

Does caching reduce the bill?

Yes, materially: prompt-cache reads are an order of magnitude cheaper than cold prompt tokens. Stable prompts and scoped sessions let the cache hit instead of re-paying full price for repeated context.

How do I audit each request's cost?

Use an endpoint whose workspace shows per-request cost, tokens, and latency with export — and a machine-readable price list you can check against. That combination turns the invoice into an audit trail.

All posts