The per-token price on a pricing page is exact, but it prices one request. An agent task sends many requests, and each request carries the whole conversation again. Cache writes, thinking tokens, compaction and failed runs add more requests that nobody typed.
In one of our benchmark runs, a Claude Sonnet 4.6 trial read 1.22 million tokens from the prompt cache. By our arithmetic, the cache accounted for about 72% of that trial's $0.76 cost. To see the cost of AI coding tools on your team, divide weekly spend by merged pull requests.
A data team rolls out Claude Code, sets a budget from the price list, and gets a bill that does not match the budget. The price list was correct. The cost of AI coding tools depends on how many tokens one finished task consumes, and the price list says nothing about that number.
As of September 2026, Anthropic lists Claude Sonnet 4.6 at $3 per million input tokens and $15 per million output tokens. Those rates apply to each API request. One agent task, such as "add a not-null test to this dbt model", sends dozens of requests. Each request carries the full conversation so far, plus every tool result the agent has collected.
Anthropic's own Claude Code costs documentation puts the average at about $13 per developer per active day. It also gives a range of $150 to $250 per developer per month, across enterprise deployments. For a five-person data team that works 20 days a month, $13 a day comes to $1,300 a month. That average is a planning number, and your own mix of models and session habits moves it in either direction.
Spend grows past the list price in five places inside one task. Each place has a habit or a setting that controls it, and a weekly query shows which one moved your bill.
The Cost of AI Coding Tools Depends on Tokens per Finished Task
A token price is an input to your bill. The count of tokens per finished task is the multiplier. Two teams on the same plan, with the same price per token, can pay very different amounts for the same work.
Five mechanisms raise the token count of one task:
- The agent sends the whole conversation again with every request.
- The prompt cache charges extra to store that conversation.
- Thinking tokens bill at the output rate.
- Compaction reads the whole conversation and writes a shorter version of it.
- A failed or retried run bills the same as a run that worked.
None of the five shows up as a line item on the price list. All five show up on the invoice. A sixth cause sits with the vendor, in tokenizers, fees and model changes. Why token counts differ between vendors covers that cause.
Claude Code Sends the Whole Conversation With Every Request
Claude Code sends your full conversation with every request, says its cost guide. Each time the agent uses a tool, Claude Code sends another request that carries the tool results. So a one-line question late in a long session pays for everything above it.
A data engineering session grows fast. The agent reads a schema listing, a manifest.json excerpt, a compiled SQL file and a dbt build log. All four stay in context. The next request carries all of them again, whether the agent still needs them or not.
Anthropic's doc names the usual cause of high spend on an API plan. The doc traces high spend to long sessions nobody cleared, and to Opus left as the default model. Run /clear between unrelated tasks. The doc says a fresh start with /clear costs nothing.
Prompt Caching Cuts Re-Read Cost to One Tenth of the Input Price
Prompt caching makes the repeated context cheaper, and it adds a charge of its own. On Anthropic's price list, a cache read costs 0.1x the base input price. A cache write costs 1.25x the base input price for a 5-minute lifetime, and 2x for a 1-hour lifetime.
For Sonnet 4.6, that means $0.30 per million tokens read from cache and $3.75 per million written with the 5-minute lifetime. Anthropic's pricing page says caching "pays off after one cache read for the 5-minute duration". A cache that expires before the next request only adds the write premium.
A short cache lifetime can erase the saving. The costs doc says the first message after a break longer than the cache lifetime misses the cache and reprocesses the full context. On an API key, that lifetime is five minutes by default. A developer who reads a query plan for ten minutes and then asks a follow-up pays to process the whole session again.
Thinking Tokens and Compaction Add Requests You Never Typed
Anthropic bills thinking tokens at the output rate. The costs doc says the default budget "can be tens of thousands of tokens per request". At Sonnet 4.6's $15 output rate, 20,000 thinking tokens cost $0.30 before the agent writes a line of SQL. The same doc says you can lower the budget on models with a fixed thinking budget:
# Lower the thinking budget for simple tasks on fixed-budget models
export MAX_THINKING_TOKENS=8000
Compaction is the second request you never typed. The doc warns that compacting "a large context is itself a large request." Auto-compaction runs when a session nears its context limit. At that point, the conversation is at its largest.
Agent teams multiply both effects. In plan mode, agent teams use about 7x more tokens than standard sessions, the doc says. Each teammate keeps its own context window. For simple subagent jobs, the doc recommends Haiku in the subagent file:
# .claude/agents/dbt-test-runner.md frontmatter
name: dbt-test-runner
description: Runs dbt tests and returns only the failures
model: haiku
Failed and Retried Runs Are Billed Like Successful Ones
A run that produces wrong SQL is billed at the same rates as a run that produces correct SQL. The provider bills tokens, and it has no view of whether your dbt build passed. So every retry adds a full run to the cost of one finished task.
We measured this in a plugin experiment on Claude Sonnet 4.6. On a cross-warehouse migration task, bare Claude produced zero working output in 5 attempts. Five runs were billed, and none of them produced a model you could merge.
Our DataAgentBench run shows the same effect at a larger scale. Claude Sonnet 4.6 ran 270 trials at an average of $0.76 each, so the run cost about $205. Of those 270 trials, 100 failed. In 32 trials, the agent never wrote an answer. Those 100 failed trials were billed at the same token rates as the 170 that passed. The per-trial price never shows how much of the spend bought a wrong answer.
One Sonnet 4.6 Trial Spent 72% of Its Cost on the Prompt Cache
Our 540-trial DeepSeek and Sonnet cost test published the token mix of an average Claude Sonnet 4.6 trial. Each trial wrote 49,000 tokens to Anthropic's prompt cache and read 1.22 million tokens back. It spent zero reasoning tokens, and it cost $0.76.
The arithmetic below is ours. It uses the list prices above and the 5-minute cache lifetime. The post does not state which lifetime the run used.
| Line | Tokens per trial | Rate per million | Cost |
|---|---|---|---|
| Cache reads | 1,220,000 | $0.30 | $0.37 |
| Cache writes | 49,000 | $3.75 | $0.18 |
| Uncached input and output | not published | $3 in, $15 out | $0.21, the remainder |
| Total per trial | $0.76 |
One average Sonnet 4.6 trial from our DataAgentBench run, split by our arithmetic at list prices.
Cache reads and writes together come to $0.55, or about 72% of the $0.76. Without the cache, the same 1.22 million tokens at the $3 input rate would cost $3.66 on their own. The average trial made 36 tool calls, so the agent re-read roughly 34,000 tokens for each call. With the 1-hour lifetime, the writes cost $0.29 and the cache share rises.
For this trial, context size moved the cost more than the price per token did. If every re-read had missed the cache, the input alone would have cost $3.66, nearly five times the trial. A trimmed schema payload saves money on every one of those 36 re-reads.
Our Benchmark Runs Show Cost per Trial Moving in Both Directions
A cheaper model per token can cost less per task, and a more expensive setup can still be worth paying for. Two of our own runs show both cases.
| Run | Setup A | Setup B | What changed |
|---|---|---|---|
| DataAgentBench, 270 trials each | Claude Sonnet 4.6, $0.76 per trial | DeepSeek v4 pro, $0.29 per trial | The model, with the same agent and tools |
| ADE-Bench, 43 tasks, Claude Sonnet 4.5 | No skills, $0.33 per task, 20 of 43 solved | With skills, $0.40 per task, 23 of 43 solved | Skills added, with the same model |
Cost per attempt from two of our benchmark runs. A model swap cut it, and adding skills raised it.
On DataAgentBench, DeepSeek v4 pro ran at 38% of Sonnet's per-trial cost and scored 3.5 points lower on stratified Pass@1. It also left 79 of 270 trials with no answer, against 32 for Sonnet. On ADE-Bench, skills raised the cost of each attempt by 21% and solved three more tasks. Neither per-attempt number tells you which setup is cheaper per finished task.
To compare the setups, divide total spend by the tasks that passed, so the failures count against each setup. Cost per completed task shows that calculation as a SQL query over logged attempts. The costs that sit on top of tokens, such as review time and rework, belong in the same calculation. The costs that sit above the license price lists them for three agents.
Deterministic Tools Remove LLM Calls From Validation
Some checks have exactly one right answer, and a compiled tool answers them without calling a model. Altimate Code, which is an AI data engineering agent, ships such tools. The altimate_core_validate tool checks SQL syntax and schema references in a Rust library, with no LLM call.
The cost difference comes from the loop. Without the tool, the agent learns about a wrong table name from a warehouse error, then re-reads its context and tries again. Our launch post describes a wrong table name that the tool catches in 2 ms, where Snowflake returns the error after 30 seconds. Five fix cycles took 10 ms against 2.5 minutes of warehouse round-trips. The zero-token schema check follows one column rename through that loop.
Compiled checks that cost nothing per run covers the wider argument. The altimate-code check command runs lint, validate, safety, policy, PII, semantic and grade checks without a model provider or API key.
This approach has limits, and you should plan for them:
- The agent still spends tokens to call the tool and to read its result, so a tool call is never free.
- Altimate does not lower the price per token. With your own LLM key, you pay the provider at its own rates.
- In our plugin experiment on Claude Sonnet 4.6, the plugin cut aggregate cost by 18.6% on three medium ADE-Bench tasks that both setups passed.
- On the simplest model-creation tasks, the same plugin added about 25% cost with no gain in correctness.
We ran each setup once or twice, so treat these percentages as a direction only.
Measure Cost per Merged Pull Request Before You Switch Models
Start with one number your team can track each week: AI spend divided by merged pull requests. The number is rough. It still counts retries and failed sessions, and a price list counts neither.
Take spend from the most authoritative source you have. The costs doc names the Usage page in the Claude Console for API billing, and the /usage figure is only an estimate. Teams plans export a spend report CSV per user and model. OpenTelemetry export streams per-user token and cost metrics on every setup.
-- ai_spend_daily: one row per engineer per day, loaded from your billing export
-- merged_prs: one row per merged pull request, loaded from your git host
with spend as (
select date_trunc('week', usage_date) as week, sum(usd) as usd
from ai_spend_daily
group by 1
),
merged as (
select date_trunc('week', merged_at) as week, count(*) as merged_prs
from merged_prs
group by 1
)
select
s.week,
s.usd,
m.merged_prs,
round(s.usd / nullif(m.merged_prs, 0), 2) as usd_per_merged_pr
from spend as s
left join merged as m on m.week = s.week
order by s.week;
Watch the trend for four weeks before you change anything. A rise with flat pull request counts points at context growth, cache misses or retries, in the order this post covers them. Then change one thing, such as a smaller thinking budget or a Haiku subagent. Compare the next four weeks against the first four.
To take validation calls out of the model loop, install Altimate Code with npm install -g altimate-code and run altimate-code check on one dbt project.
Frequently Asked Questions
The hidden cost is the number of tokens one finished task consumes. Each agent request carries the whole conversation. Cache writes, thinking tokens, compaction and failed runs add cost on top. The price per token stays the same while the tokens per task grow.
Anthropic's costs documentation gives an average of about $13 per developer per active day. It also gives $150 to $250 per developer per month across enterprise deployments. It says 90% of users stay below $30 per active day.
Prompt caching lowers the cost of repeated context to 0.1x the base input price on Anthropic's price list. A cache write costs 1.25x for a 5-minute lifetime or 2x for a 1-hour lifetime. A cache that expires between requests only adds the write premium.
Run /usage in Claude Code to see the session's token counts and an estimated cost. The doc calls that figure an estimate. For authoritative API billing, use the Usage page in the Claude Console.
Deterministic tools remove the model call from a check, such as schema validation. The agent still spends tokens to call the tool and read the result. They cut cost on checks with one right answer, and they do not change the price per token.
