halfoff.dev
Get a key
Guide

The cheapest way to use the Claude API

Seven ways to lower a Claude API bill, ordered by how much they usually save: model choice, prompt caching, output limits, thinking, batching and price.

Prepaid, no subscriptionREST or MCPOne key for models, data and agents

A Claude API bill is tokens times price, so there are only two ways to make it smaller: send fewer tokens, or pay less per token. Most guides cover the first. This one lists both, in the order they usually pay off, so you can stop at the point where the bill stops mattering. Each step says what to change and how to check it worked.

01

1. Use the smallest model that passes your test

The biggest saving is usually a model change, not an optimisation. Write ten to twenty real inputs with the answers you'd accept, run them on the small model, and move up only when it fails. Classification, extraction, routing and short summaries are normally fine on the smallest Claude. Reserve the largest for work where a wrong answer is expensive: hard code changes, long analysis, anything an agent can't undo. Opus vs Sonnet vs Haiku has a decision table, and the price table shows the gap between them.

02

2. Cache everything that repeats

Anything you send on every request, such as tool definitions, a system prompt, a policy document or the conversation so far, can be read from the cache at a small fraction of the input price. Add cache_control to the last block of the stable prefix:

Python
response = client.messages.create(
    model="claude-sonnet-5.5",
    max_tokens=1024,
    system=[{"type": "text", "text": LONG_INSTRUCTIONS, "cache_control": {"type": "ephemeral"}}],
    messages=messages,
)
print(response.usage.cache_read_input_tokens)

If cache_read_input_tokens is zero on the second call, the prefix changed or is below the minimum length. Prompt caching lists the usual causes, and for agents and long chats it is the saving that matters most.

03

3. Cap the output

{}

Output tokens cost several times input tokens, so a long answer is the most expensive thing a model can do. Set max_tokens to what the task needs, ask for the format you will parse (a label, a JSON object, three bullets), and say "no preamble" when you'd otherwise strip it. Check stop_reason: if it is max_tokens often, you cut answers off and should raise the cap or shorten the ask, not ignore it.

04

4. Turn thinking down

{}

Extended thinking is billed as output. For tasks that don't need long reasoning, leave thinking off, or choose a low effort setting, and compare the answers on your test set. You pay for thinking tokens whether or not you read them.

05

5. Send less input

  • Retrieve the three relevant sections, not the whole manual.
  • Trim chat history after a point, or replace old turns with a short summary.
  • Drop tool definitions the request can't use.
  • Compress images before sending them: image tokens grow with resolution.

POST /v1/messages/count_tokens tells you how big a request is before you pay for it. See the Anthropic API guide.

06

6. Batch the work that can wait

If a job doesn't need an answer now, such as nightly classification of a backlog, run it off-peak and in bulk instead of one interactive call at a time, and keep the shared prefix identical across the batch so every call after the first reads it from the cache.

07

7. Pay half the list price

Steps 1 to 6 reduce tokens. This one reduces the price of each token: Half Off Dev serves the same Claude models through the same Anthropic Messages API at half of Anthropic's list price, for input, output, cache reads and cache writes alike. It stacks with everything above, because it multiplies the final bill. Moving takes two changes:

Shell
export ANTHROPIC_BASE_URL=https://halfoff.dev
export ANTHROPIC_API_KEY=ho-...

Your SDK, prompts, tools and streaming code stay the same. Start with the quickstart and compare your own numbers in the calculator.

08

Frequently asked questions

?
What is the cheapest Claude model?+

The smallest model in the family, which is what the live price table sorts to the bottom. Whether it's the cheapest for you depends on whether it passes your test cases: a cheap model that needs three retries costs more than a mid-sized one that gets it right.

Does prompt caching reduce the cost of Claude Code?+

Yes, and it matters more there than anywhere. A coding session resends the whole history every turn, so most of its input is cached reads. How much Claude Code costs shows where the rest goes.

Is it cheaper to use the Claude API than a Claude subscription?+

It depends on how much you use it. Light and bursty use is cheaper on the API; heavy daily use can be cheaper on a flat plan. Claude Pro vs the API works through when each wins.

Will I get the same answers at half the price?+

You get the same models through the same API: requests are passed to the vendor's own format without translation, so features like cache_control and thinking behave as Anthropic documents them.

Where do I start?+

Use the cost calculator on your real token counts, then create an account and send one request.

One prepaid key for models, data and agents

No subscription. Top up, use what you need, see every charge in your logs.