Token Cost Per Merged PR
Cost per merged PR divides everything a team spends on AI coding assistance in a period by the number of pull requests that reached the main branch in that period. Spend includes metered API tokens, seat subscriptions, and review bots. The denominator counts only merged work, so abandoned branches and rejected attempts raise the figure instead of vanishing from it.
A token is a chunk of text, roughly three-quarters of an English word, and somewhat less for dense code. Vendors bill four kinds: fresh input, output, cache writes, and cache reads. At Anthropic’s list prices checked in November 2026, Claude Sonnet 5.5 costs $2 per million input tokens, $10 per million output tokens, $2.50 per million for a five-minute cache write, and $0.10 per million for a cache read.
Take one agent session that produces a medium-sized PR over about 40 turns. It reads 3 million cached tokens ($0.30), writes 250,000 to cache ($0.63), sends 150,000 fresh input tokens ($0.30), and generates 60,000 output tokens ($0.60). Total: about $1.83.
That is the cost of one attempt, not of one merged PR.
Why Estimates Miss
Teams usually budget from the output side because generated code is what they see. Output is the smaller share of volume. An agent resends the conversation history, file contents, and tool results on every turn, so input volume grows roughly with the square of the turn count. Without caching, the 3 million re-read tokens in the example above would bill at $2 per million, turning $0.30 into $6.00.
Caching has its own trap. The standard cache entry lives five minutes. A developer who steps away for coffee returns to an expired cache, and the next turn rewrites the whole context at 1.25 times the input rate, which, frankly, nobody notices until the monthly export.
Merge rate is the other blind spot. If 60% of AI-started attempts end in a merge, the $1.83 session becomes about $3.05 per merged PR before any seat fees. Add a review bot that reads each diff and a CI-fix loop that reruns after failing tests, and the figure climbs again.
The metric also depends on plumbing. You need usage data keyed to a person or repository, a way to link sessions to pull requests, and a consistent rule for which PRs count. Claude Code exports token and cost metrics over OpenTelemetry, GitHub exposes Copilot usage through its metrics API, and a proxy such as LiteLLM can tag requests by team. None of these join to PR data on their own.
Building The Budget
Capture Spend At The Source
Pull billing data from the vendor’s usage and cost export, not from individual developers’ estimates. Tag API keys per team or per repository so spend splits cleanly. Add seat fees as a fixed monthly line. For context, Anthropic has said enterprise Claude Code deployments average about $13 per developer per active day, or roughly $150 to $250 per developer per month, which gives a sanity check for your own totals.
Count The Right Pull Requests
Decide the denominator once and write it down. A defensible rule: PRs merged to the default branch, excluding dependency bumps from bots and pure reverts. If you want AI-attributed PRs only, use commit trailers such as Co-Authored-By or a PR label applied by the tool. Expect gaps. Developers paste suggestions from chat windows that leave no trace, so attributed counts run low.
Route Work By Model Tier
Model choice moves the bill more than any prompt tweak. On the same sample session, Claude Opus 5.5 at $4 input and $20 output costs about $3.65, double Sonnet 5.5. Claude Haiku 5.5 at $0.10 and $0.50 comes to about $0.11, with one catch: prompts over 100,000 tokens shift the whole request to a higher rate of $0.50 and $2.50. Send test scaffolding, renames, and lint fixes to the small model, keep the mid tier as default, and reserve the top tier for multi-file refactors where a failed attempt costs more than the price gap.
Set Caps And Review Monthly
Put a per-developer monthly ceiling in the vendor console and an alert at 80%. Then track three numbers each month: total spend, merged PRs, and merge rate of AI-started attempts. A falling cost per PR with a falling merge rate means people are splitting work into smaller PRs, not getting more efficient. You watch the spend, check the merge rate, and the trend line starts to mean something.
Two Team Scenarios
A product team of 12. The team runs metered API access with Sonnet-class models as default. One month’s export shows $2,640 in token spend, or $220 per engineer. The repository shows 310 merged PRs after excluding bot updates. Cost per merged PR: about $8.52. Digging in, the manager finds two engineers account for 35% of spend, both running long sessions on a legacy module with large files. The fix is dull: a project instruction file that tells the agent which directories to skip, and shorter sessions with a fresh context per task. Next month lands near $7. Not a headline.
A five-person agency. The agency uses flat-rate seats and assumes its cost is fixed. Two developers hit plan usage limits mid-month and switch to API keys on the top model tier to finish a client deadline. The overflow adds several hundred dollars nobody budgeted. Their cost per merged PR for that client turns out to be roughly triple the agency average, driven by a monorepo where each session loads far more context. They now price that client’s retainer with the difference in mind.
Model Tiers Compared
| Model Tier | Input / Output Per 1M Tokens | Cache Read Per 1M | Sample Session Cost |
|---|---|---|---|
| Claude Haiku 5.5 | $0.10 / $0.50 (prompts up to 100K tokens) | $0.01 | About $0.11 if every request stays under the 100K threshold |
| Claude Sonnet 5.5 | $2 / $10 | $0.10 | About $1.83 |
| Claude Opus 5.5 | $4 / $20 | $0.20 | About $3.65 |
The sample session assumes 3 million cache-read tokens, 250,000 cache-write tokens, 150,000 fresh input tokens, and 60,000 output tokens. Prices are Anthropic list rates as checked in November 2026 and will change. Other vendors use the same four-part structure with different numbers, so rerun the arithmetic with your own provider’s rate card.
Common Mistakes
Dividing by all PRs when only some used AI, or by AI-labelled PRs when labelling is patchy. Either choice is fine if it stays constant. Switching between them makes month-to-month comparison meaningless.
Treating the metric as a productivity score for individuals. Engineers who take the hard tickets burn more tokens per PR. Rank people by it and they will pick easy tickets, and the dashboard rarely tells you that happened.
Ignoring review cost. An AI reviewer that reads a 2,000-line diff plus surrounding files on every push can cost more than the session that wrote the code.
Comparing against salary alone. A $9 PR sounds trivial next to an engineer’s hourly cost, but the token bill is added to that salary, not substituted for it. The fair comparison is time saved per PR, which needs its own measurement.
Budgeting from a quiet month. Usage climbs as developers grow comfortable delegating longer tasks, so base the forecast on the latest four weeks and the trend.
FAQ
What is a typical AI token cost per pull request?
It varies widely with repository size and model. Single agent sessions on a mid-tier model often land between $1 and $5, and team-level figures including failed attempts and seats commonly run higher, in the $5 to $15 range.
Why are input tokens the biggest part of the bill?
Agents resend history and file contents every turn. A 40-turn session can read millions of tokens while writing tens of thousands, so input volume dominates even at a lower unit price.
Does prompt caching reduce coding assistant costs?
Yes. Cached reads on Sonnet 5.5 bill at 5% of the fresh input rate. Savings shrink when sessions pause past the cache lifetime, because the context must be written again.
Is a flat subscription cheaper than paying per token?
For steady, moderate use, usually. Heavy users can exceed plan limits and spill into metered billing. Compare your last month’s token export against the seat price before choosing.
How do I track AI spend per developer?
Issue separate API keys or workspace members per person, export usage from the vendor’s admin console or API, and join it to merged PR data from your Git host by author and date.
Author’s Insight
Working through vendor rate cards, the pattern that stands out is how little of the bill comes from the code an assistant writes and how much comes from what it reads. That shifts the useful questions from prompt wording to context hygiene: file sizes, session length, and what the agent is told to ignore. Cost per merged PR is a blunt instrument, since it says nothing about PR size or quality, yet it has one property finance teams need, which is that both halves of the fraction come from systems of record. Published evidence on real team costs is still thin and mostly vendor-supplied, so internal data deserves more trust than any benchmark, including the ranges given here.
Key Takeaways
- Cost per merged PR equals total AI spend divided by merged pull requests, with failed attempts left in the numerator.
- Four token types drive the bill: fresh input, output, cache writes, and cache reads. Re-read context usually outweighs generated code.
- At November 2026 list prices, the same sample session costs about $0.11, $1.83, or $3.65 across three Claude tiers.
- Merge rate converts session cost into PR cost. A 60% rate lifts $1.83 to about $3.05.
- Fix the counting rule, tag spend by team, cap per-developer usage, and review monthly alongside merge rate.
- Use the metric for budgeting, not for ranking engineers. Rates change often, so recheck the vendor’s pricing page before forecasting.