§04 — the arbitrage, priced by you
It will also tell you the batch wasn’t worth a fleet
Offline batch inference is roughly five to ten times cheaper per token than
online serving, and spot GPUs cut another 60–90% off on-demand.
forge cost turns the real usage forge
captured into the invoiceable difference — and it never guesses a
price.
# a 50M-item summarization run — ~35B input / ~7.5B output tokens —
# the rent you actually paid: rate x wall-clock hours x GPUs,
# priced against an online rate you also supply
$ forge cost --results results.jsonl \
--gpu-usd-per-hour 5.00 --gpu-hours 50 --gpus 8 \
--online-per-mtok-input 0.50 --online-per-mtok-output 1.50
forge: $2000.0000 ($0.0471/Mtok · 21250000 tokens/$)
online: $28750.0000 → saved $26750.0000 (93.0%)
Both sides of that sum are yours. forge does not shop for GPUs and
does not know what spot costs today — it multiplies the rate you give
it by the hours the run took, and prices the same tokens against the online
rate you also give it. Pass --gpu-cost instead if you already
have one figure for the run. What forge contributes is the token
side: those totals are summed from the real usage the
engines reported, not estimated from your input file.
It is honest in the other direction too: on a job too small to amortise the
GPU bill the saved figure goes negative, which tells you the batch
was not worth a dedicated fleet. Cached-prompt tokens price at the full
input rate unless you pass a discounted rate for them — conservative
by default, so the saving is never overstated.
Against the alternative
Cloud Batch APIs hide the operational pain but give a flat ~50% discount, with no choice of model weights, data locality or GPU economics. forge is the other trade: you keep all three, and you own the procurement decision — forge runs the shell, it does not buy your GPUs.
Keep the prefix cache hot
--prefix-bucket reorders the input by shared (model, system-prompt) so the engine's automatic prefix cache actually stays warm and those cached_tokens materialise instead of being theoretical.
The only numbers on this page that are not measured
The GPU rate, the hours and the online prices above are an
illustration — plausible figures put through the real
arithmetic, not a run anybody performed. Everything else here comes from a
harness in the repository. Substitute your own four numbers and the answer
changes completely, which is the entire point of the command.