Cost calculator

Estimate AI coding token cost per applied patch.

The useful unit is not one API request. For AI coding, the useful unit is an accepted patch. tokenpatch reports executor usage, estimated all-strong baseline, actual executor cost, and savings ratio after each bounded run.

MetricFormulaWhy it matters
All-strong baselineStrong model input/output tokens x strong model priceApproximates what the task would cost if the expensive model did all implementation work.
Executor actualExecutor input/output tokens x executor priceShows the lower-cost implementation spend for the bounded patch.
Savings ratio(baseline - actual) / baselineTurns token savings into a task-level percentage that is easy to compare across runs.
Cost per applied patchActual executor cost / accepted patch countFilters out vanity request metrics and focuses on useful code changes.

Example

If the all-strong estimate is $0.42 and tokenpatch execution costs $0.08, the estimated savings ratio is 81%.

What to track

Track baseline, executor usage, accepted patch status, validation result, and whether the diff stayed inside allowed files.

What not to overfit

Do not optimize only for cheapest tokens. A failed patch can cost more than a slightly stronger executor that lands the change.