Every team evaluating an AI coding agent hits the same wall at the same moment. The demo is impressive, the first pull request lands, and then someone in the room asks the only question that decides whether this becomes real: what does it cost to run, and can we control it?

The honest answer is that AI coding agent cost is not a mystery and not a fixed number. It is the predictable output of a few things you can see and change: how many tokens a task burns, which model runs each step, how much of the work you can cache or batch, and whether you have a ceiling that stops a runaway. Get those in view and the bill stops being scary and starts being a dial.

This guide is the map of that dial. It covers what an agent actually costs, the levers that cut the bill, the business model underneath any product built on top of a model, and the build-versus-buy and return-on-investment questions that decide whether the whole thing is worth it. Each section links to a deeper piece if you want to go further.

What an AI coding agent actually costs

Start with the unit. A realistic agentic coding task is not one prompt. As of mid-2026, a representative task runs on the order of 200,000 input tokens and 30,000 output tokens once you count the context an agent reads and the code plus reasoning it produces. That single number already tells you two useful things.

It also lets you compute a real figure instead of guessing. Take a mid-tier model at roughly $3 per million input tokens and $15 per million output tokens (rates move, so check them before you quote them). One pass of that task costs about 200,000 / 1,000,000 times $3, which is $0.60 of input, plus 30,000 / 1,000,000 times $15, which is $0.45 of output. Call it about $1.05 for a single clean pass. Run the same task on a top-tier model at $5 and $25 and the same pass is closer to $1.75. Neither number is scary on its own. The scary part is what multiplies it.

The first multiplier is the model choice, and it matters enormously. Frontier model pricing is published, and while the exact rates move, the shape is stable: a top-tier model can cost several times what a mid-tier one does, and a small model can be an order of magnitude cheaper again. Running every step on your most capable model is the most common way teams overpay.

The second is that output is the expensive half. Across the major models, output tokens cost roughly five times what input tokens cost. A verbose agent that narrates every step and regenerates whole files is a costly agent, and trimming what it emits is one of the cheapest wins available. This is worth understanding on its own, which is why why output tokens dominate your bill is its own piece.

Then there is the multiplier almost nobody prices in at first: the loop. An agent works in turns, and a naive agent re-sends its entire history on every turn, so token use grows closer to quadratically than linearly with the length of a session. A ten-turn session can cost far more than ten times a single call. Concretely, that ~$1.05 clean pass can become $3 to $8 once a typical task needs a few implement-and-test iterations, and a genuinely tangled task that spirals through many rounds can run into the tens of dollars. That dynamic, and how to blunt it, is covered in agent loops and quadratic token growth.

Put those together and you can see why a flat "cost per feature" figure is misleading. A one-line change that lands on the first pass and a tangled refactor that needs five rounds of fixing differ by more than an order of magnitude, and they should. The reliable way to a number is to reason from the token math of a task, which the token math of an agentic coding task walks through step by step, and then to calibrate against real runs rather than a spreadsheet, which is the heart of what an AI coding agent actually costs per feature.

Cutting the bill

Once you see a task as a sequence of runs, the ways to cut cost stop being tricks and become obvious structural choices. There are four that do most of the work, and they stack.

The first is caching the stable part of the prompt. Repo-grounded agents send a large, mostly unchanging block of context on every run. Prompt caching charges that repeated prefix at a steep discount, often around a tenth of the normal input rate, so the bigger and more stable your context, the more caching saves. In our worked example, the 200,000-token input is mostly a stable repo-context prefix; caching it can take that $0.60 of input toward roughly $0.06 on cached runs. For an agent that reads the same codebase slice over and over, this is close to free money, and it is the single most effective lever for grounded work. The details are in prompt caching, the cheat code for repo-grounded agents.

The second is routing each step to the cheapest model that can do it well. Most work in an agent pipeline is not hard reasoning. Classification, formatting checks, simple extraction, and routine judgments can run on a small model, while planning and difficult implementation justify a premium one. Public results suggest 60 to 80 percent of tasks can be handled by a model 10 to 100 times cheaper than the frontier, with careful routing cutting spend dramatically at little quality cost. The catch is real and worth stating: route something to a model that turns out not to be good enough and the failure is quiet, a missed nuance rather than an error. Model routing, send the cheap work to the cheap model covers how to draw that line safely.

The third is batching the work that is not time-sensitive. Analysis, offline checks, and background passes do not need an answer this second, and a batch path is typically half price. Running latency-insensitive work at full interactive rates is simply leaving a discount on the table, as batch the boring half of your pipeline explains.

The fourth is a ceiling. Most of the scary tail of a bill is an agent grinding on a task it will not finish. A hard cap on iterations and spend per task, with an escalation to a human when the cap is hit, turns an unbounded risk into a bounded, forecastable one. This is as much about sleeping at night as saving money, and it is the subject of capping runaway agent spend.

Stack these and public reports of 60 to 85 percent reductions are believable, not marketing. Caching takes the biggest, most repeated cost near zero; routing moves the bulk of steps to a cheaper tier; batching halves the offline lane; the cap removes the catastrophic tail. None of them requires a better model. They require using the model you have deliberately.

The business model underneath

If you are not just running an agent but building a product on one, the economics change shape, and it is worth being clear-eyed because AI products are not classic software.

The uncomfortable fact is that inference is a real, variable cost on every request. That pulls gross margins down from the 80 to 90 percent that pure software enjoys toward something more like 50 to 60 percent, because cost of goods sold is back in a way SaaS founders spent a decade forgetting. The problem compounds with success: your heaviest, most engaged users are also your most expensive to serve, so growth and cost climb together. Ignore it and you can sell a product that loses money on its most engaged users. AI product margins, why COGS is back works through what that does to a P&L.

There is one structural choice that changes the whole risk profile: who owns the model account. In a bring-your-own-model design, the tool calls the provider with the customer's own key, so the customer pays for inference directly, at list price, with no markup, and the vendor carries near-zero variable cost. It is the honest version of the pitch, and it removes the margin-compression problem at its root, though it trades away per-token revenue and adds a little onboarding friction. The trade-offs are laid out in bring your own model, pricing without token-margin risk.

Whatever you decide on inference, you still have to price the thing. The frameworks that hold up separate a platform fee for the software and support from any usage or outcome component, so the predictable value and the variable cost are not tangled into one confusing number. How to price an AI product covers the models that work and the ones that quietly punish your best customers.

Build versus buy, and whether it is worth it

Two decisions sit on top of all of this, and they are the ones a founder actually loses sleep over.

The first is build versus buy. Standing up your own agent orchestration, evaluation, and cost controls is real, ongoing engineering, not a weekend. The prototype that wires an agent to your repo is the cheap 10 percent; the reliability, evaluation, security, and on-call that production demands are the other 90. Buying a platform trades that effort for a subscription and less control. The right answer depends on how core the capability is to you and how much undifferentiated plumbing you are willing to own, and build vs buy an internal agent platform gives an honest framework rather than a foregone conclusion.

The second is the plainest question of all: is it worth it? An agent that costs a few dollars a task and saves an engineer an hour is easy math. An agent that costs more in review and rework than it saves is a net loss dressed up as innovation. The answer turns on your task mix, your review cost, and your quality bar, and is an AI coding agent worth it, a cost-benefit read gives you a way to actually run the numbers for your situation.

The honest limitation

Everything here reduces uncertainty. None of it removes it. Token math gives you a range, not a guarantee, because real repositories are messier than any model of them. Routing saves money right up until a cheap model quietly gets something wrong and you pay for it downstream in a bug. Caching helps only when your context is actually stable. And no cost model survives a change in provider pricing, which moves more often than anyone would like, so every figure here is a shape to verify, not a quote to bank on.

So treat cost as something to forecast and bound, not something to pin to a number. The teams that stay in control are not the ones who found a magic cheap setup. They are the ones who measured their real spend, set ceilings, and matched each lever to their actual workload. Your first week of real usage will teach you more than any a-priori estimate, and the right posture is to calibrate against it rather than defend a spreadsheet.

That is the stance we take with Loopsfinity: you bring your own model account, so inference is billed to you directly at public rates with no markup, and every lever above, the model per step, the caching, the batching, the caps, is yours to set and see. We would rather hand you an honest range you control than a round number you cannot verify, because when the question is whether to let an agent ship your product, a cost answer is only useful if you can trust where it came from.