# LLM token budgets: a practical guide to cost control

Part of: [LLM Inference and Context](https://ninadpathak.com/articles/ai-engineering/)

LLM token budgets from real figures: what a token costs, why input dominates a bill, why a chat costs more each turn, and where to cut first.

Canonical: https://ninadpathak.com/articles/llm-token-budgets/

By Ninad Pathak (https://ninadpathak.com/about/). Published 2026-04-17, updated 2026-11-18.

AWS's billing alarm fires after the money is spent, and its [documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html) is exact about when it fires. The alarm "triggers only when the current billing exceeds the threshold" and "doesn't use projections based on your usage so far in the month."

An LLM token budget is a limit on what one request or one period is allowed to spend, set before the spending happens. It can refuse a request where the alarm can only report money already gone, because [tokens can be counted](https://platform.claude.com/docs/en/build-with-claude/token-counting) before anything is sent.

Budgets are the cost side of [LLM inference](https://ninadpathak.com/articles/ai-engineering/), which is otherwise measured in latency and throughput.

A pair of Amazon engineers [published on November 9](https://strandsagents.com/blog/amazon-saves-millions-replacing-sonnet-with-strands-decider/) the token counts for their ticket-labeling agent: 6,554 input tokens and 170 output tokens per ticket on Claude Sonnet 4.6. That put 89% of the model bill on input by my arithmetic, and input is the prompt that gets sent again on every call, so it is where a budget has to look first.

## What does a token cost?

A token's price depends on the model and on whether it is input or output, and output costs five times as much as input on Claude Sonnet 5.5. Anthropic's [pricing page](https://platform.claude.com/docs/en/about-claude/pricing), read on November 17, 2026, lists these rates for Claude Sonnet 5.5 in USD per million tokens.

| Token type | Price per million tokens, USD |
| --- | --- |
| Input | 2.00 |
| Output | 10.00 |
| Cache write, five minutes | 2.50 |
| Cache read | 0.10 |

The number of tokens in a prompt changes between models too. The pricing page says Claude 4.7 and later models use a tokenizer that "produces approximately 30% more tokens for the same text", so a prompt counted on Sonnet 4.6 is a low estimate for Sonnet 5.5.

## Where does the money go in one call?

For a call with a long standing prompt and a short answer, nearly all of it goes to input. Amazon's post describes the workload: "The agent ran with a long system prompt on every ticket, generating JSON and reasoning against a fixed set of labels."

The script below reproduces their cost per ticket from the token counts, then prices a second workload, a 20-turn chat.

```python
"""Two token budgets: one ticket-labeling call, and a 20-turn chat that replays its history."""

# 1. Amazon's published figures for labeling one ticket with Claude Sonnet 4.6.
IN_PRICE, OUT_PRICE = 3.00, 15.00            # USD per million tokens
in_tokens, out_tokens = 6_554, 170
in_cost = in_tokens * IN_PRICE / 1e6
out_cost = out_tokens * OUT_PRICE / 1e6
print(f"ticket: ${in_cost + out_cost:.4f} per call, {in_cost / (in_cost + out_cost):.0%} of it input")
print(f"        ${(in_cost + out_cost) * 1e6:,.0f} per million tickets")

# 2. A chat on Claude Sonnet 5.5 list prices: 2.00 in, 10.00 out, cache write 1.25x, cache read 0.05x.
IN, OUT, WRITE, READ = 2.00, 10.00, 2.50, 0.10
system, user, reply, turns = 1_500, 150, 250, 20



def chat(expires_every=None):
    """Cost of the chat. expires_every=5 means the cache has lapsed before every fifth turn."""
    plain = cached = 0.0
    history = 0
    first = last = 0.0
    for turn in range(1, turns + 1):
        prompt = system + history + user                  # everything sent this turn
        new = user + reply if turn > 1 else prompt        # tokens the cache has not seen
        if expires_every and turn % expires_every == 0:
            new = prompt                                  # cache lapsed: the whole prompt is written again
        cost = prompt * IN / 1e6 + reply * OUT / 1e6
        plain += cost
        cached += (prompt - new) * READ / 1e6 + new * WRITE / 1e6 + reply * OUT / 1e6
        first = cost if turn == 1 else first
        last = cost
        history += user + reply
    return plain, cached, last / first, system + history - reply


plain, cached, ratio, last_prompt = chat()
print(f"chat:   turn 1 sends {system + user:,} input tokens, turn {turns} sends {last_prompt:,}")
print(f"        turn {turns} costs {ratio:.1f}x turn 1 without caching")
print(f"        20 turns: ${plain:.4f} without caching")
for label, every in (("cache never lapses", None), ("lapses before every 5th turn", 5),
                     ("lapses before every 2nd turn", 2), ("lapses before every turn", 1)):
    _, cached, _, _ = chat(every)
    print(f"        {label:<29} ${cached:.4f}  ({1 - cached / plain:+.0%} saved)")
```

```text
ticket: $0.0222 per call, 89% of it input
        $22,212 per million tickets
chat:   turn 1 sends 1,650 input tokens, turn 20 sends 9,250
        turn 20 costs 3.6x turn 1 without caching
        20 turns: $0.2680 without caching
        cache never lapses            $0.0831  (+69% saved)
        lapses before every 5th turn  $0.1393  (+48% saved)
        lapses before every 2nd turn  $0.2091  (+22% saved)
        lapses before every turn      $0.3225  (-20% saved)
```

The ticket cost in that output agrees with the per-ticket figure in the post's own table.

The post is about replacing Sonnet 4.6 with a much smaller model, [Strands Decider](https://github.com/strands-labs/strands-decider), and its publisher has an interest in the result. It appears on the Strands Agents site, which AWS publishes, the team ran Strands Decider on SageMaker instances that AWS bills for, and its opening paragraph says the swap "performed just as well at 98% less cost".

I'm using only the Sonnet column of their table for costs. A pair of figures from the other column applies to any model: the Strands Decider prompt was 2,009 tokens against 6,554, and its output was one token against 170, so part of the saving came from sending less and asking for less.

## Why does a chat cost more with every turn?

Each turn resends the system prompt and the whole conversation so far, so the input grows while the question stays the same size. The twentieth turn in the run above sends 9,250 input tokens against 1,650 for the first, and costs 3.6 times as much.

<figure class="np-figure">
  <a class="np-figure-zoom" href="https://ninadpathak.com/static/images/diagrams/llm-token-budgets/token-budget.svg"><picture><source media="(max-width: 712px)" srcset="https://ninadpathak.com/static/images/diagrams/llm-token-budgets/token-budget.narrow.svg" width="288" height="248"><img class="np-has-narrow" src="https://ninadpathak.com/static/images/diagrams/llm-token-budgets/token-budget.svg" width="720" height="280" alt="Six turns of a chat, each drawn as one request: the system prompt, the replayed history of every earlier turn, the new message, and the answer. Because history is replayed on every turn, each request is longer than the last." loading="lazy" decoding="async"></picture></a>
  <figcaption>A bot that replays its full history pays for the same tokens again on every message, so each turn costs more than the one before.</figcaption>
</figure>

Prompt caching is the direct answer, because the resent part is identical from one turn to the next. With the unchanged prefix read from cache the conversation costs 69% less, and Anthropic's page says "Caching saves money after a small number of cache reads".

The 69% figure assumes every turn arrives before the cache lapses, a window the price table gives as five minutes, and people in a chat often pause for longer. With the cache lapsing before every fifth turn the saving in the run is 48%, and with a lapse before every turn caching costs 20% more than going without.

A cached prefix shortens the wait as well as the bill, which is the subject of [time to first token](https://ninadpathak.com/articles/time-to-first-token/).

The other answer is to stop resending everything. Compaction replaces old turns with a summary, as [short-term memory for agents](https://ninadpathak.com/articles/short-term-agent-memory/) describes, and how models use a long window is set out in the [context window guide](https://ninadpathak.com/articles/llm-context-windows/).

## What should a token budget enforce?

A budget should enforce a hard stop, per request and per month. Simon Willison [argued on October 3](https://simonwillison.net/2026/Oct/3/default-hard-budget-caps/) for the monthly kind as a default on every paid API: "after $X/month, cut this thing off and return errors".

His reason is that a warning doesn't stop the spending. "Soft caps, "after $X/month, send me a warning email", will not cut it."

A per-request budget is the same idea at a smaller scale. Cap the output with the API's `max_tokens` parameter, and reject a prompt over a set size before it is sent.

## Where should you cut first?

Start with what is sent on every call. The script's output backs the first two steps below, the price list backs the next two, and the fifth is Amazon's result.

1. Shorten the standing prompt, since it is paid for on every request.
2. Cache the part of the prompt that doesn't change between requests.
3. Cap the output length, because output tokens carry the higher price.
4. Move work that can wait to a batch endpoint, which Anthropic prices "with a 50 percent discount on both input and output tokens".
5. Try a smaller model where the task is a choice from a fixed list of labels.

The smaller-model step is Amazon's result, and their own caveat belongs with it: "This worked because the task is a closed choice from a known catalog, the volume is high, and the latency of the old path mattered."

---

Work with me: email hello@ninadpathak.com, or book a 30-minute call at https://zcal.co/ninadpathak/meet

Services: https://ninadpathak.com/services/
