Which cost reductions cannot cost you an answer, in what order, and when to stop
Twelve steps, four parts, three runnable workloads — seven decisions, four of them free, and a stop between the two groups.
- All 12 steps, read online
- Runnable labs to download (plain Python, runs offline)
- Free updates whenever it's revised
- 14-day refund (conditions)
Introduction
You have a model in production and a bill that is larger than you expected. You have heard the standard advice — cache it, trim it, use a cheaper model — and no way to tell which of those applies to your traffic, in what order, or when to stop.
The two ways a cost reduction can fail
Almost everything written about this subject addresses the first and is silent about the second.
| # | how it fails | worst case | how you would find out |
|---|---|---|---|
| 1 | it saves nothing — the move was real and your traffic had nothing for it to act on | the engineering time is gone | the bill does not move |
| 2 | it costs an answer — the bill fell and something you needed stopped working | you ship a wrong answer | you might not |
The whole of Part 2 is an ordering that keeps those two apart, with a stop between them.
What token cost engineering is
Token cost engineering is the practice of reducing what a workload costs to run without losing the answers you needed from it.
Seven decisions in a fixed order. Four of them cannot change any answer you get; three of them buy money with answers; and decision 4 is the question is that enough? This volume measures all seven on three workloads by holding the model fixed — the tiers are scripted and deterministic — so a change in the outcome can only have come from the decision.
| # | decision | what it asks | kind |
|---|---|---|---|
| 1 | itemize the bill | split what you are paying for by what was counted | risk-free |
| 2 | reuse a stable prefix | stop paying full price for the same leading tokens | risk-free |
| 3 | stop paying twice | serve a repeated request from what you already answered | risk-free |
| 4 | stop generating early | stop once the answer is complete | risk-free |
| 5 | send only what is needed | trim the context to what the request uses | risk-free |
| 6 | choose a tier | send what a cheaper tier can answer to the cheaper tier | trades answers |
| 7 | check, and escalate | check the answer and re-ask the failures at full price | trades answers |
The three findings, up front
Is this for you?
| if… | then |
|---|---|
| you do not know which half of your bill to attack | step 4, and the answer is probably not the half you think |
| you are about to cache and trim in the same sprint | step 5. They fight, and nobody says so |
| you are considering a cheaper model | step 7 first, then step 6 — you may not need to |
| you are adding a check to catch a cheap tier's mistakes | step 10. Check which requests it fires on before you build it |
| somebody asked what a wrong answer costs and you had no number | step 11. That number decides the whole thing |
The three workloads
Twelve requests each, declared by ratios you can measure on your own system. The one that predicts behavior is prefix reuse — which refuted the specification, where the repair workload was expected to be output-heavy because it writes code.
| the traffic | prefix reuse | competence spread | untouched bill | |
|---|---|---|---|---|
A · answer | twelve questions over four documents that do not change | high | narrow | $3.371 |
B · fix-a-test | twelve repairs in one module, in a different state each time | low | narrow | $6.492 |
C · triage | twelve questions about one failure, across several artifacts | medium | wide | $4.809 |
How the measurement works
Scripted tiers, one fixed request order, no clock and no randomness, and every figure
reproducible byte for byte from 105 measured configurations. --ablate prints four
blocks, and each answers a different question:
| block | what it does | what it hides |
|---|---|---|
| the ladder | switch the decisions on one at a time, in order | that one of them is negative once another is already on |
| leave-one-out | remove each move from the complete procedure | nothing — but its savings column recommends deleting your risk-free moves, and step 6 explains why |
| downshift baseline | everything on the cheap tier, then one router added | nothing here — this is where the three routers become comparable |
| stress | vary one premise at a time: the mix, the target, what a rule sees | that the largest single effect on quality is a premise about your requests |
Read the savings column and the score column together, always. A configuration that saved more and answered worse did not find a better cut — it took a different exit, and step 6 is where that costs a reader money.
How to read the source labels
| label | means |
|---|---|
| concept | argued from first principles, quotes nothing from a lab |
| measured | a lab compares configurations and reports the difference |
| hands-on | you run it on your own material |