Shipping a feature with AI agents typically costs a few dollars in model tokens — but the number that matters is cost per shipped feature, not cost per token. That means counting the retries, the failed runs, and the chunking decisions that never made it into the diff, then dividing total spend by features that actually merged. Anyone quoting you "$0.30 per PR" without that denominator is quoting you a marketing number, not a cost.
Almost nobody publishes real AI development cost economics. Vendors quote token prices because token prices are small and impressive. They don't quote cost per feature because that number includes the runs that failed, the context that had to be rebuilt after a bad edit, and the human review cycles that follow. This article is the honest version, with the arithmetic shown.
Why does the token bill understate the real cost?
Every serious LLM provider — Anthropic, OpenAI — bills across at least four buckets, and most teams only track one or two:
- Input tokens — the prompt, code context, and instructions you send. Usually the cheapest per-token rate.
- Output tokens — the generated code, explanation, and reasoning. Priced 3-5x higher than input on most models.
- Cache creation tokens — the first time you send a large, reusable context block (a repo summary, a PRD, a style guide), providers charge a premium to write it into cache.
- Cache read tokens — subsequent reads of that cached block are cheap, but only if your pipeline is actually structured to reuse context instead of resending it cold.
Collapse these four into "tokens used" and you lose the ability to answer a basic engineering question: is a feature expensive because the model is generating a lot of code, or because your agent pipeline keeps re-sending the same 40k-token repo context on every retry? Those are different problems with different fixes. One is a prompting/architecture fix; the other is a model-choice fix.
How do you track AI token spend per project?
You need a usage ledger, and it needs a key granular enough to answer "why did this cost what it cost" six weeks later. The minimum viable key is:
tenant → feature → stage → run
- Tenant — which customer or workspace incurred the cost (critical if you bill usage back, or if you're on shared infrastructure).
- Feature — the actual unit of value being built, e.g. "add CSV export to reports."
- Stage — PRD generation, planning, code generation, test generation, review/fix loop. Costs concentrate differently at each stage.
- Run — a single agent execution, including retries. This is the row that lets you see failed attempts, not just the successful one.
Log the four token buckets per run, plus the model used (pricing varies by model generation, not just provider), plus a status field (succeeded, retried, abandoned). Without the abandoned runs in the ledger, your average cost per feature is quietly wrong — often by 2-4x — because the failures are invisible until you sum everything at the tenant level and wonder why the bill doesn't match the "cost per PR" you were quoted.
Why is per-run pricing hard to compare?
Per-run pricing looks clean in a pricing table — "$2 per agent run" — but it quietly asks the customer to pay for your retries. If a feature needs one clean run, it costs $2. If the same feature needs four attempts because the model misread the schema or the test suite flaked, does it cost $8? Whoever answers "yes" is pricing their reliability problems into the customer's bill, and whoever answers "no" is absorbing the variance with no way to show the customer why.
Per-feature or per-PR pricing is the more honest and more comparable unit, because it forces the vendor to own the retry cost internally and only bill for the outcome — a merged pull request. It also matches how engineering leaders actually think about ROI: nobody budgets in "agent runs," they budget in delivered features, the same unit DORA metrics and DORA research use to measure delivery performance. If you're evaluating vendors, ask directly: is your unit price per run, or per shipped outcome? The answer tells you who's holding the retry risk.
What does a worked example look like?
Take a mid-complexity feature: "add role-based access control to the reporting module." Here's a realistic run breakdown using a mix of large-context and standard model calls:
| Stage | Runs | Input tokens | Output tokens | Cache read | Cost |
|---|---|---|---|---|---|
| PRD generation | 1 | 8,000 | 2,500 | 0 | $0.11 |
| Planning / architecture | 2 (1 retry) | 22,000 | 6,000 | 18,000 | $0.34 |
| Code generation | 3 (2 retries) | 60,000 | 28,000 | 90,000 | $1.92 |
| Test generation | 1 | 15,000 | 4,500 | 12,000 | $0.22 |
| Review/fix loop | 4 (3 retries) | 48,000 | 16,000 | 60,000 | $0.95 |
| Total | 11 runs | $3.54 |
That $3.54 is the honest cost of this feature — not the $0.85 you'd get if you only counted the final successful run at each stage. The 6 retries account for roughly 60% of total spend. That ratio, retry cost as a share of total, is one of the most useful numbers you can track over time: it tells you whether your pipeline is getting more reliable (ratio falling) or your feature complexity is creeping up (ratio rising).
Scale that to 40 features shipped a month and you're at roughly $140/month in model spend — trivial next to one engineer's salary, which is exactly why vendors like to quote the token number alone. The real cost conversation is about engineering time spent reviewing, not model spend. But you can't have that conversation credibly if your cost-per-feature number is already wrong by 4x.
How should you set budget controls without breaking the pipeline?
Two different controls get confused constantly, and they solve different problems:
- Per-run ceilings — a platform safety measure. Caps how much any single agent run can spend before it's killed, protecting against runaway loops or context bloat. This is an engineering control, invisible to the customer, tuned by whoever operates the pipeline.
- Per-period spend caps — a customer budget tool. Caps total spend across a tenant per billing period (day, week, month). This is a business control, visible to the customer, and it should map to their actual budget conversation, not to your infrastructure limits.
Conflating the two means either your safety rail is set so loose it never protects anything, or your customer-facing budget cap is set so tight it kills legitimate retries mid-feature. Set them independently, log which one triggered when a run stops, and surface per-period spend to the customer in the same unit they think in — dollars per month, not tokens per run.
Does using your own API key change the cost?
Yes — it changes who sees the bill, not just how it's calculated. With bring-your-own-key (BYO-key), token cost flows directly to the customer's own provider account, at their negotiated rate, visible in their own billing dashboard. Without it, the vendor absorbs and marks up token cost inside a flat or seat-based price, and the customer never sees the four-bucket breakdown at all. If you're running on-prem or self-hosted models, this decision also intersects with data residency and model choice — worth understanding before you commit to either model, since switching later means re-instrumenting your entire ledger.
Where does this fit into an actual delivery pipeline?
Cost tracking is only useful if it's attached to a pipeline that produces shipped features, not just agent output. VocxAI turns customer feedback into shipped code — it ingests signals from your support and feedback tools, prioritises what to build, and runs an AI agent pipeline from PRD to pull request with human approval at every gate. Every stage in that pipeline — PRD, planning, code generation, test generation, review — is a natural place to key your usage ledger, which is exactly the tenant → feature → stage → run structure described above.
If you're deciding whether to automate feature development end-to-end, it's worth reading how the pipeline stages break down before you try to cost them. And if prioritization is still manual, the cost-per-feature number means less until you know which features were worth building in the first place.
FAQ
How much does it cost to generate code with AI?
Raw token cost for a single successful generation is usually cents to a few dollars, depending on model and context size. The honest number — including retries and failed runs — is typically 2-4x higher once you account for the full pipeline needed to reach a mergeable PR.
What is cost per feature in AI development?
Total token spend (input, output, cache creation, cache read) across every run and stage required to ship one feature — including failed attempts — divided by one. It's the only cost unit that maps to business value, since "features shipped" is what engineering leaders and finance actually budget against.
How do you track AI token spend per project?
Build a usage ledger keyed by tenant → feature → stage → run, logging all four token buckets, model used, and run status (succeeded, retried, abandoned) at each row. Without the abandoned runs, your averages will understate true cost.
Why is per-run pricing hard to compare?
Because it bills customers for the vendor's retries. A feature needing one run and a feature needing five runs cost different amounts under per-run pricing, even though the customer receives the same outcome. Per-feature or per-PR pricing forces the vendor to own that variance.
Does bring-your-own-key change the cost?
It changes visibility more than magnitude — with BYO-key, token spend hits the customer's own provider account directly at their rate; without it, the vendor absorbs and marks up the cost inside a flat or seat-based fee, and the breakdown by token bucket disappears from the customer's view.
See how VocxAI builds this for you
VocxAI connects your customer signals to your revenue data and surfaces a ranked, revenue-weighted product backlog - automatically, every week.
Join the private beta