Skip to content
AVERITH
← All insights
AI EconomicsNote / 0211 min read

The cost of an AI workflow is not the cost of an API call

The useful denominator is a completed outcome. Retries, tools, fallback models and abandoned runs all belong in the cost model.

Most AI cost conversations start with a price sheet: a rate per million input tokens, a higher rate per million output tokens, perhaps a discount for cached input. Those numbers are accurate and nearly useless for deciding whether a workflow is economically viable. They describe the price of one call. The business pays for something else.

What the business buys is a completed outcome: a ticket resolved, a claim triaged, a contract reviewed, a report produced that someone actually accepts. Getting there may take several model calls, a handful of tool invocations, retrieval, a validation step, a retry, occasionally a more expensive fallback model, and sometimes a human. Some runs never finish at all, and their cost is spent anyway.

The useful unit is therefore not cost per call or cost per token. It is cost per completed outcome, and its denominator only counts runs that produced something of value.

One workflow run / where spend accrues

REQUESTTOOLS +RETRIEVALATTEMPTVALIDATERETRYCOMPLETEDFALLBACKMODELABANDONED← DENOMINATORCOMPLETED ONLYNUMERATOR / EVERY BOX ABOVE: ATTEMPTS, TOOL CALLS, RETRIEVAL, VALIDATION, RETRIES, FALLBACKS, ABANDONED WORKCOST PER COMPLETED OUTCOME = TOTAL SPEND ACROSS ALL RUNS ÷ COMPLETED OUTCOMES
Figure 1 — Spend accrues at every step of a run, including steps that never lead to a result. Only completed outcomes belong in the denominator.

01 / Unit

Choose the denominator before you optimize the numerator

Cost per call measures a component. Cost per run measures an attempt. Neither tells you what a unit of delivered work costs, because neither accounts for runs that fail, loop or are abandoned. The definition that survives contact with finance is:

The hard part is defining “completed”. A response returned without an error is not a completed outcome. A completion should mean the result met the acceptance bar for that workflow: it passed validation, the user did not redo the work, or a reviewer approved it. A definition that counts wrong answers as completions makes the economics look better precisely as quality gets worse.

02 / Anatomy

A single attempt is already many costs

Before retries enter the picture, one attempt at a workflow typically includes far more than one model call.

  • Input tokens for the system prompt, instructions, tool schemas, retrieved context and conversation history, sent again on every call.
  • Output tokens, usually priced higher than input, and on reasoning models often including internal reasoning tokens the user never sees.
  • Retrieval: embedding the query, vector and keyword search, and reranking, each with its own compute or per-request cost.
  • Tool execution: third-party API fees, database load, sandboxed code execution or browser sessions.
  • Guardrails and validation: classifiers, schema checks, policy checks or a second model acting as a judge.
  • Observability and storage: traces, logs and the evaluation data needed to operate the system responsibly.

Multi-step agents add a growth effect. If every step re-sends the accumulated history, input tokens grow with each turn. With a base prompt of b tokens and d tokens added per step, an n-step run sends roughly n·b + d·n(n+1)/2 input tokens in total. The second term is quadratic: doubling the number of steps roughly quadruples the accumulated-context cost. Prompt caching and context summarization exist largely to bend that curve.

03 / Failure

Failed and abandoned runs are paid for in full

A run that fails validation still consumed every token it used. If a single attempt costs c and succeeds with probability p, and failures are retried independently until success, the expected cost per success is c ÷ p. At a 50% first-pass success rate, each completed outcome costs twice the attempt price before any other overhead.

Abandonment is subtler. A user who closes the window halfway through a slow agent run leaves behind partial spend and no outcome. Long-running workflows, slow responses and clarifying questions the user does not answer all produce this kind of cost, and it never appears in a per-call view.

This is why improving first-pass quality is usually the strongest economic lever. A better prompt, better retrieval or a tighter tool contract that lifts success rate reduces the cost of every outcome, while a cheaper model with a lower success rate can raise it.

04 / Fallbacks

Fallback models and cascades change the cost curve

Fallbacks exist for two reasons. Availability fallbacks route to a second provider or model when the primary is down or rate-limited. Quality fallbacks escalate to a stronger, more expensive model when a cheaper one fails. Both alter the cost distribution, and both are frequently missing from cost models.

Cascades are a deliberate version of the quality fallback: try a cheap model first, check the result, and escalate only when needed. Research such as FrugalGPT and RouteLLM shows that well-designed cascades and routers can reduce cost substantially while preserving quality on the evaluated tasks.12 The economics depend on three quantities:

Availability fallbacks have the opposite problem. They are rare, so nobody measures them, until a provider incident routes a whole day of traffic to a more expensive model, or to a cheaper one whose lower success rate triggers a wave of retries.

05 / Example

A worked example

The following example is illustrative, with round numbers chosen to make the arithmetic visible. Suppose one call is priced at 1 unit, and a single attempt of the workflow costs 8 units once growing context, retrieval and validation are included. Of 100 runs: 70 complete on the first attempt; 10 are abandoned midway at roughly half an attempt’s cost; 20 fail validation and are retried. Of those, 15 complete, and 5 fail again and escalate to a fallback model that costs three times as much per attempt; 3 of those complete.

Line itemCalculationUnits
First attempts90 full attempts × 8 units, plus 10 abandoned midway × 4 units760
Retries20 failed first attempts retried × 8 units160
Fallback model5 runs that failed twice, escalated × 24 units120
Total spend1,040
Completed outcomes70 first-pass + 15 after retry + 3 after fallback88

The cost per completed outcome is 1,040 ÷ 88 ≈ 11.8 units. That is nearly twelve times the per-call price that appears on the price sheet, and about one and a half times the per-attempt figure a team might reasonably have budgeted. None of the individual numbers is extreme. The gap comes entirely from counting work that did not produce an outcome.

06 / Hidden

The costs outside the invoice

Model spend is the most visible line, which is why it attracts the most attention. Production AI systems carry the same hidden operating costs that Sculley et al. described for machine-learning systems more broadly: glue code, pipelines, configuration and monitoring that outweigh the model itself.3

  • Human review and correction, including the cost of fixing outcomes that were accepted but wrong.
  • Evaluation runs on every prompt, model or retrieval change, which consume tokens without serving a user.
  • Index rebuilds and re-embedding when content, chunking or embedding models change.
  • Engineering time spent on incidents caused by provider changes, rate limits and silent model updates.

These costs do not belong in every per-outcome figure, but they belong in the decision about whether a workflow is worth automating at all.

07 / Instrumentation

Attribute every cost to a run and an outcome

None of this can be managed without attribution. Every model call, tool call and retrieval operation should carry a run identifier, and every run should end in an explicit terminal state.

  • Record per call: run ID, step, model, input, cached and output tokens, tool costs, latency and the price-table version used to compute cost.
  • Record per run: terminal state such as completed, failed, abandoned or escalated_to_human, the number of attempts and whether a fallback was used.
  • Version the price table. Provider prices change, and historical comparisons are meaningless if old runs are re-priced at today’s rates.
  • Report cost per completed outcome alongside completion rate, so a cost reduction that harms quality is visible immediately.

08 / Levers

Levers that actually move the number

Once the denominator is right, the levers become clear, and several of them have nothing to do with model price.

  • Raise first-pass success with better retrieval, clearer tool contracts and validated output schemas.
  • Set per-run budgets for steps, tokens and wall-clock time, and fail fast instead of looping.
  • Trim and cache context: stable prefixes first, summarized history, and only the retrieved passages that matter.
  • Route by workload with an evaluated policy rather than defaulting every request to the largest model.
  • Measure abandonment and reduce latency where users give up, because a faster run is often a cheaper one.

The price of an API call will keep falling. Whether an AI workflow is economically viable will still depend on how many attempts, tools, fallbacks and abandoned runs it takes to produce one outcome someone is willing to accept.

References

  1. 1. Chen, L., Zaharia, M. and Zou, J. (2023). FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance. arXiv:2305.05176
  2. 2. Ong, I. et al. (2024). RouteLLM: Learning to Route LLMs with Preference Data. arXiv:2406.18665
  3. 3. Sculley, D. et al. (2015). Hidden Technical Debt in Machine Learning Systems. Advances in Neural Information Processing Systems 28. NeurIPS 2015

About the author

Author

Chandan Mohanty

Senior Software Engineer, Wipro

Works on large-scale data platforms at Wipro. Contributed the evaluation design in this note.