An agent pays for what it reads, not only for what it writes. Every step resends the system prompt, the files and the conversation so far, so most of the bill is the same context being read again and again.
The short version, from our own requests on December 1, 2026:
- caching a long system prompt halved the cost of every request after the first;
- a small model wrote the same working function as a flagship one for $0.00025;
- asking for three sentences cut a reply from 855 to 342 tokens and the request cost by 40%;
- a running summary instead of the full history cut input tokens over six turns from 1,519 to 422.
All requests went through the WRAITHERIX API. Costs come from the usage log in the dashboard, token counts from the usage field of each response.
Cache the context that never changes
If every request starts with the same large block, mark it for caching. The first request writes it to the cache; later requests read it at a fraction of the normal input price.
We turned a 22,616-character source file into a system prompt ("review this code") and asked claude-sonnet-4-6 a short question three times:
| Request | Read from cache, tokens | Charged |
|---|---|---|
| 1st | 0 | $0.0326 |
| 2nd | 5,520 | $0.0159 |
| 3rd | 5,646 | $0.0145 |
From the second request on, the file came from the cache and the price halved. Our request had no explicit marker; the cache worked on its own. You can mark a cacheable block explicitly with cache_control on the system block (we did not measure that variant separately):
"system": [
{
"type": "text",
"text": "...long instructions or file...",
"cache_control": {"type": "ephemeral"}
}
]
The cache lives for a few minutes, which suits agents well: they call the model often enough to keep it warm. Agent tools often add the marker for you. If you build your own loop, you can add it and check the usage log: from the second request you should see cache reads.
Match the model to the step
Renaming a variable, writing a regex or parsing JSON does not need a flagship model. We gave three models the same task: a Python function that validates an email with one regular expression.
All three returned a working function with the same pattern. claude-haiku-4-5 used 36 input and 48 output tokens and cost $0.00025. A flagship model gives the same answer at a higher price; compare claude-opus-4-6 and claude-haiku-4-5 in the catalogue.
Watch reasoning models on tiny tasks. deepseek-v4-flash produced 278 output tokens for a one-line function, and 224 of them were reasoning before the answer. Reasoning is billed as output, so a "cheap" reasoning model can cost more than its per-token price suggests.
A setup that works: a strong model plans and reviews, a small one runs the routine steps. Many agents let you set a separate model for background work.
Ask for the length you need
Output tokens cost several times more than input on most models, and models like long, structured answers. We asked claude-sonnet-4-6 "why can a long conversation with an AI agent get expensive?" twice, once with no instructions and once with "answer in at most 3 short sentences, no lists, no headings":
| Variant | Output tokens | Charged |
|---|---|---|
| No instructions | 855 | $0.0217 |
| At most 3 sentences | 342 | $0.0131 |
When the reply goes to another program rather than a person, make the format strict: code only, JSON only, one word.
Send a summary, not the whole history
An agent that resends the full conversation grows its input every turn. We ran the same six-step scenario on deepseek-v4-flash (build a minimal Flask app, add a route, add logging, summarise) in two ways: full history in every request, and a short running note of what was done plus the new question.
Over six turns the full-history version read 1,519 input tokens and the summary version 422. By turn six the full history was 501 tokens per request against 105, and the gap keeps widening.
In money the difference in this test was small, $0.00133 against $0.00116: the model is cheap and most of the cost was output. The same pattern on a large model with real files over an hour-long session reaches hundreds of thousands of tokens, and then compression is where the savings are. Claude Code, for example, has a /compact command for this.
A summary drops detail, so keep the exact facts (file paths, function names, decisions) as an explicit list inside it.
Which one first
- One large shared context (a codebase, a knowledge base): cache it.
- Many small repetitive steps: move them to a small model.
- A program reads the output: fix a short format.
- Long sessions: compress the history or restart the conversation.
Per-request costs, including cache reads, are in the WRAITHERIX dashboard usage log. Prices per million tokens for every model are in the catalogue.
How we tested
December 1, 2026, macOS 27.2.1, Python 3.11, direct calls to the WRAITHERIX API (/v1/messages for the caching test, /v1/chat/completions for the rest). Models: claude-sonnet-4-6, claude-opus-4-6, claude-haiku-4-5, deepseek-v4-flash. These are single requests, not a benchmark over thousands of calls, so your numbers will differ; the size of the effect should not.
