How it works

How to save tokens on the Claude API

Saving tokens on the Claude API comes down to three levers: send fewer input tokens, generate fewer output tokens, and pay less per token through model choice and prompt caching. Each lever is a concrete change to the requests you already send — and all of them stack with the apiToken.sale discount, which cuts the price side of the equation in half.

·

Where Claude API tokens actually go

Your Claude API bill is input tokens plus output tokens, metered separately per model. Two facts in the rate card tell you where to optimize: output tokens cost five times more than input on every current Claude model, and a multi-turn conversation resends its entire history as fresh input on every call. So the biggest savings come from generating less output, resending less context, and letting cheaper token classes — cache reads and smaller models — do more of the work.

ModelOfficial in / out ($ per 1M)Here (−50%)
Claude Opus 4.8$5 / $25$2.50 / $12.50
Claude Sonnet 5$2 / $10$1 / $5
Claude Haiku 4.5$1 / $5$0.50 / $2.50

Read that table as a routing table, not just a price list. Haiku is five times cheaper than Opus per token at both input and output, and the flat 50% B2C discount halves every row without changing the ranking — so model choice saves the same proportion here as it does against official pricing.

See also: How Claude API pricing works

Cache the context you resend on every request

Prompt caching is the single largest token saver for anything with a stable, repeated prefix: long system prompts, tool definitions, large reference files. You mark the end of the stable block with a cache_control breakpoint; the first call writes the cache (metered separately), and subsequent calls read it back at a fraction of the fresh-input price. A cache entry lives about five minutes, and every read refreshes it, so an active session keeps its cache warm indefinitely.

curl https://router.apitoken.sale/v1/messages \
  -H "x-api-key: sk-pool-•••" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "system": [
      {
        "type": "text",
        "text": "<your long, stable system prompt>",
        "cache_control": {"type": "ephemeral"}
      }
    ],
    "messages": [{"role":"user","content":"Refactor the parser."}]
  }'

Cache matching is prefix-exact: change one byte early in the prompt and everything after that point is re-billed as fresh input. Put volatile content — timestamps, user state, the current question — after the cached breakpoint, never before it.

Route each request to the cheapest model that can handle it

Sending every request to Opus is the most expensive habit in Claude API usage. Most production traffic — classification, extraction, formatting, autocomplete-style edits, tool-result parsing — does not need frontier reasoning, and paying Opus rates for it is pure waste. Match the model to the task and the per-token spread does the saving for you.

  1. 01Default new workloads to claude-sonnet-5 — the balanced tier for everyday coding and writing.
  2. 02Push high-volume or mechanical work down to claude-haiku-4-5: tagging, summarizing short inputs, schema conversion, simple Q&A.
  3. 03Escalate instead of defaulting: run the cheap model first and retry on claude-opus-4-8 only when the answer fails your checks.
  4. 04Inside agent loops, keep planning on the strong model but run parsing and formatting steps on Haiku.

The classic pattern is a cascade: Haiku attempts the request, a cheap validation decides whether the output is acceptable, and only failures climb to Sonnet or Opus. You pay frontier prices only for the small share of traffic that genuinely needs it.

Send less context, ask for less output

Every file, message and tool definition in the request is billed again on every call, and every token of the reply is billed at the 5× output rate. Trimming both sides is unglamorous but immediate — it requires no platform features, just discipline about what goes into the request.

  • Send only the files and history a task actually needs; a targeted excerpt beats a whole-repo dump.
  • Summarize long threads into a running brief instead of resending the full transcript each turn.
  • Drop tool definitions the current step cannot call — they are billed as input on every turn.
  • Cap max_tokens to what the response really requires; a runaway completion is billed to the last token.
  • Ask for a diff or patch instead of a full file rewrite, and for JSON when you parse the reply anyway — prose padding is billed at output rates.

Because output costs five times input, trimming 1,000 output tokens saves as much as trimming 5,000 input tokens. When in doubt, shorten the answer you ask for before you shorten the context you send.

Read the usage object before you tune anything

Every Messages API response ends with exact accounting in its usage field. Log these numbers per feature or endpoint before optimizing — guesses about where tokens go are usually wrong, and the usage object turns optimization into arithmetic.

"usage": {
  "input_tokens": 1520,
  "output_tokens": 212,
  "cache_creation_input_tokens": 8134,
  "cache_read_input_tokens": 0
}

On a warm cache, most of your input should move into cache_read_input_tokens while plain input_tokens collapses to the new question alone. The apiToken.sale dashboard shows the same token-level breakdown for every request, so you can watch the shift happen after each change instead of waiting for the monthly bill.

Estimate your monthly spend in the free calculator

Token discipline and the discount compound

Billing on apiToken.sale runs in a fixed order: each call is converted to official Anthropic spend from its exact usage components — input, output, cache write, cache read — then the flat 50% B2C discount is subtracted, and the net amount is drawn from your prepaid balance. Caching and routing shrink the official spend; the discount halves whatever remains. The two multiply, so a workload that cuts its token count in half effectively costs a quarter of the official price.

The balance itself never expires and top-ups accept any whole-dollar amount, so there is no subscription clock pressuring you to burn tokens you would rather save. Current per-model rates, including cache pricing, are on the models page.

Current model lineup and per-model pricing

Frequently asked questions

What is the single biggest way to save tokens on the Claude API?

Prompt caching for large, repeated context — system prompts, files, tool definitions — combined with routing each task to the cheapest model that can do it. Cache reads cost a fraction of fresh input tokens, and Haiku is five times cheaper per token than Opus.

How do I see how many tokens a Claude API request used?

Every response carries a usage object with input_tokens, output_tokens, cache_creation_input_tokens and cache_read_input_tokens. The apiToken.sale dashboard shows the same per-request token breakdown.

Which Claude model should I use to save money?

Default to claude-sonnet-5 for everyday work, drop high-volume mechanical tasks to claude-haiku-4-5 ($1/$5 per 1M officially, $0.50/$2.50 with the discount), and reserve claude-opus-4-8 for genuinely hard reasoning.

Does setting max_tokens lower my Claude API bill?

You pay for output tokens actually generated, so a tight max_tokens cap prevents runaway completions from billing to the limit. If a reply ends with stop_reason: max_tokens, the cap cut the answer off — raise it deliberately rather than retrying the same request.

Do these token-saving tactics stack with the apiToken.sale discount?

Yes. Caching and model routing reduce the number of tokens billed at official rates, then the flat 50% B2C discount halves what remains — the savings multiply.

Create an account with Google or GitHub and test the gateway with $5 of platform bonus credit.