Token price is one input to an AI budget. The engineering question is what it costs to produce an output someone can actually use. An inexpensive response that fails review can be more costly than a larger response that needs little correction.

Define the useful unit

Write an acceptance rule before measuring. Your unit might be an approved support draft or a reviewed research summary. An API request, a user task and an accepted output are different denominators. State which one the budget uses.

The FinOps Foundation's unit economics capability discusses connecting technology costs to meaningful units. Apply that idea to the outcome your team needs, rather than treating token volume as the outcome.

Draw the cost boundary

Include initial model calls, retry calls, retrieval, external tools, allocated infrastructure and human review. State whether setup, evaluation and monitoring are inside the period. Keep the boundary consistent when comparing configurations.

Record actual billed usage when available. If a cost is estimated, label it estimated and save the price source and effective date. Do not treat a dashboard estimate as a reconciled invoice. Account for cached input or different request classes only when the records identify them.

Calculate the unit cost

Total cost equals the included cost components. Cost per accepted output equals total cost divided by accepted outputs. If no outputs are accepted, the unit cost is undefined; report the spend and the failure.

A hypothetical monthly example has $20 of initial calls, $5 of retries, $10 of retrieval, $15 of allocated infrastructure and $50 of review time. Total cost is $100. With 80 accepted outputs, unit cost is $1.25. These numbers are invented teaching inputs, not provider prices or customer results.

If only 50 outputs are accepted at the same $100 cost, the useful-output cost becomes $2. The change came from acceptance, not the model's token price. Track both.

Allocate shared costs openly

A shared server does not usually provide a perfect bill for each request. Choose an allocation rule, such as measured usage or a documented share, and record its limitations. Do not silently assign all fixed costs to one test run or ignore them in another.

Review time can dominate a small pilot. Convert minutes to cost using an explicit hourly assumption. If review is already included in a separate staff-cost allocation, do not add it again.

Compare configurations fairly

Use the same representative cases and acceptance rule. Compare cost with latency, failures and review effort. Keep rejected and abandoned work visible. A cheaper configuration that shifts correction work to another team may not reduce the full cost.

Use the cost-per-useful-request worksheet and read how retries change the AI bill. Subscribe to Cloud & AI Engineering Brief for practical operating methods.

Tested addendum, October 10, 2026: choose a budget that still produces useful work

A lower invoice can hide a lower completion rate. This exercise compares four invented configurations on one task volume, with a quality floor and spending limit declared first. Its question is: which configuration stays inside the operating budget while producing enough accepted outputs?

The workload is one hundred internal support drafts for the same approved question set. Acceptance requires the answer to address the question, cite an applicable approved policy and avoid an unsupported promise. These are hypothetical counts and costs. No provider quote, company saving or customer result is reported. You need Python 3.12 or later and an empty working directory.

1. Declare the decision before opening the totals

For this lab, the maximum period spend is 120 currency units. At least 80 percent of attempted tasks must produce accepted drafts. These teaching parameters are not a suitable budget or acceptance threshold for every business.

Choose the same reporting period, input set and acceptance rule for every configuration. The five mutually exclusive cost categories are initial model calls, retries, retrieval, allocated infrastructure and review. Initial calls exclude retries. Review includes the repair labor attributed to this sample. If your invoice already includes a tool charge, do not add it again under retrieval.

Some costs are shared. Here, every configuration receives fifteen units of allocated infrastructure so that comparisons use the same boundary. A real allocation needs a recorded basis, such as measured workload share. Fixing an allocation in a teaching fixture is not a claim that actual infrastructure costs remain constant across designs.

2. Run the operating-budget comparison

Save the following as budget_lab.py:

from decimal import Decimal

D = Decimal
budget = D("120")
floor = D("0.80")
cost_fields = ("initial", "retries", "retrieval", "infrastructure", "review")
configs = [
    {"name": "baseline", "attempted": 100, "accepted": 80,
     "costs": ("20", "5", "10", "15", "50")},
    {"name": "cheaper", "attempted": 100, "accepted": 60,
     "costs": ("8", "2", "8", "15", "30")},
    {"name": "higher_quality", "attempted": 100, "accepted": 90,
     "costs": ("25", "8", "12", "15", "75")},
    {"name": "no_outputs", "attempted": 100, "accepted": 0,
     "costs": ("5", "2", "3", "15", "20")},
]

def evaluate(config):
    attempted, accepted = config["attempted"], config["accepted"]
    assert type(attempted) is int and type(accepted) is int
    assert attempted > 0 and 0 <= accepted <= attempted
    values = tuple(D(value) for value in config["costs"])
    assert len(values) == len(cost_fields)
    assert all(value.is_finite() and value >= 0 for value in values)
    total = sum(values, D("0"))
    rate = D(accepted) / attempted
    unit = total / accepted if accepted else None
    quality_ok, budget_ok = rate >= floor, total <= budget
    eligible = quality_ok and budget_ok
    return total, rate, unit, quality_ok, budget_ok, eligible

results = {config["name"]: evaluate(config) for config in configs}
assert results["baseline"][:3] == (D("100"), D("0.8"), D("1.25"))
assert results["cheaper"][0] == D("63")
assert results["higher_quality"][0] == D("135")
assert results["no_outputs"][2] is None
assert [name for name, result in results.items() if result[-1]] == ["baseline"]

print(f"policy max_spend={budget:.2f} min_acceptance={floor:.2f}")
for name, (total, rate, unit, quality, affordable, eligible) in results.items():
    unit_text = f"{unit:.2f}" if unit is not None else "undefined"
    print(f"{name} spend={total:.2f} acceptance={rate:.2f} cost_per_accepted={unit_text} "
          f"quality={'PASS' if quality else 'FAIL'} "
          f"budget={'PASS' if affordable else 'FAIL'} eligible={eligible}")
print("eligible=baseline decision=TEST_BASELINE_FURTHER")
print("data=synthetic provider_prices=0 deployments=0")

Run python3 -I budget_lab.py. Complete verified stdout is:

policy max_spend=120.00 min_acceptance=0.80
baseline spend=100.00 acceptance=0.80 cost_per_accepted=1.25 quality=PASS budget=PASS eligible=True
cheaper spend=63.00 acceptance=0.60 cost_per_accepted=1.05 quality=FAIL budget=PASS eligible=False
higher_quality spend=135.00 acceptance=0.90 cost_per_accepted=1.50 quality=PASS budget=FAIL eligible=False
no_outputs spend=45.00 acceptance=0.00 cost_per_accepted=undefined quality=FAIL budget=PASS eligible=False
eligible=baseline decision=TEST_BASELINE_FURTHER
data=synthetic provider_prices=0 deployments=0

3. Explain why the cheapest unit cost fails

The cheaper configuration costs 63 units and 1.05 per accepted output. Both are below baseline. It still fails the declared quality floor because forty tasks do not yield an accepted draft. If a person must complete those tasks manually, that fallback belongs in the cost boundary. This fixture leaves rejected work unfinished and reports that limitation. It cannot establish the price of completing all one hundred customer tasks.

The higher-quality configuration accepts ninety drafts but exceeds the budget by fifteen units. Its additional accepted work may be valuable, but this policy does not permit it. An owner could approve a different budget after examining business value. That would be a new decision with a recorded rationale, not an unnoticed revision of the original test.

The no-output configuration spends forty-five units. Dividing that amount by zero accepted outputs has no finite result. The code prints undefined. Returning zero would reverse the meaning of a complete failure and make it look free. The spend must remain visible even when its denominator disappears.

Baseline passes the two declared checks. Passing does not justify a deployment. The program has no latency target, factual-error severity measure, security assessment or statistical uncertainty. Its decision is to test further because the calculation is only one part of an operating decision.

4. Build your reporting-period record

Start from a complete provider usage export and a task ledger. Assign every attempt to a task, then record whether the final output passed review. Reconcile provider totals before applying any shared-cost allocation. Keep missing usage under an explicit unknown category instead of inventing a billable amount.

Record the effective date and source for every price assumption. Include which cached, batch or tool categories the records actually identify. This program uses attributed costs and cannot reconstruct provider request classes from token counts.

Add a separate sensitivity sheet for setup amortization and human fallback. Change one assumption at a time. Do not compare an estimate including staff repair with an invoice excluding it. If the acceptance rule changes, version it and rerun all configurations against comparable cases.

Troubleshooting and completion check

If output differs, compare all five cost fields and acceptance counts. Decimal inputs should be strings. An accepted count greater than attempted is a data-contract error. If there were no attempted tasks, report an empty reporting period separately; this exercise rejects that state rather than dividing by it.

You have completed the lab when you can identify the baseline's eligible status, explain the cheaper configuration's rejection and account for the spend with zero outputs. The next experiment should add measured fallback effort and a latency target while keeping the question set and acceptance rule fixed. That would test whether an attractive cost figure survives the requirement to finish the work.

The original script was executed with an empty inherited environment and isolated Python, and its stdout matched this block exactly. The FinOps Foundation's unit economics capability, inspected October 10, 2026, explains connecting costs to meaningful business units and their value. The thresholds, fixture and decision rule here are original teaching choices, not a certification or empirical recommendation from FinOps.