All projects

Token Optimization

A small calculator for seeing how caching, batching and shorter answers change the cost of using a language model, and what each one gives up.

Working demo
2026
React, TypeScript, NumberFlow, Token pricing
Recalculates three example workloads as you move the sliders.
It does not connect to a billing account or change live requests.
Token Planner · OverviewSample data

Monthly estimate

Illustrative rates · £3 in / £12 out per million tokens
Baseline£144.00
With changes£109.80
Saving24%
Tokens a month30.0M

Baseline against changes

Baseline£144.00
With changes£109.80

InputOutput

Each change on its own

Cached input−£27.00
Batched work−£0.00
Shorter answers−£7.20

Cache and batch discounts do not stack, so these do not add up to the combined saving.

Cost as volume grows

BaselineWith changes

5k requests£36.00 baseline, £27.45 with changes
10k requests£72.00 baseline, £54.90 with changes
20k requests£144.00 baseline, £109.80 with changes
30k requests£216.00 baseline, £164.70 with changes
40k requests£288.00 baseline, £219.60 with changes
Rates, assumptions and calculation
Monthly cost breakdown in pounds
CostBaselineWith changes
Input£72.00£45.00
Output£72.00£64.80
Total£144.00£109.80

Base cost = requests × tokens per request × rate ÷ 1,000,000. Cached input is assumed to cost 75% less, and batched requests 50% less on input and output. Cache discounts apply only outside batches. Illustrative GBP figures, not live provider prices or a forecast; they leave out cache write premiums, retries, tool calls, storage and tax.

What the project explores

A smaller bill starts with understanding the workload.

Models charge for the tokens they read and write. This interactive notebook makes that arithmetic inspectable: choose a workload, change one assumption, then compare the input and output costs. It is a pricing experiment; it does not connect to an account or change a production workload.

01 / Reuse stable input

Keep shared instructions and reference material at the start of a prompt. When a provider can reuse that prefix, the cached input can cost less. The slider represents input that actually receives a cache discount.

A repeated prompt is not a guaranteed cache hit. Prefix matching, minimum length and expiry depend on the provider.

02 / Move work off the clock

Summaries, evaluations and overnight document processing can often wait. Put eligible requests into a batch instead of paying for an immediate response. This model assumes a 50% batch discount.

Waiting is the trade-off. Keep interactive work on the synchronous path; do not assume cache and batch discounts combine.

03 / Spend output deliberately

Ask for the format and length the task needs, then measure the tokens actually returned. Output tokens often cost several times more than input, so shorter successful answers can have a meaningful effect.

A smaller token limit can cut an answer short. Compare completeness and accuracy on representative tasks before keeping a change.

Further reading: prompt caching and batch processing. Provider rules and prices vary; the figures above are deliberately illustrative.

This is an interactive calculator for language model pricing. A model reads input tokens and writes output tokens, often at different prices. The calculator starts from an example workload with a visible token profile, then shows how cache reuse, delayed batch processing and shorter answers change each part of a monthly total. It does not connect to a billing account or change live requests.

01

Why I built it

Token pricing is hard to reason about when several choices change at once. I built this to learn how each one moves the total, one setting at a time.

02

How it works

  1. Choose an example workload. Each one has its own volume and tokens per request.
  2. Change cached input, batched work and answer length, and watch each part of the bill move.
  3. Compare the changes one at a time and across volumes. Check answer quality and speed before applying a change to real work.
03

What I learned

A lower estimate only matters when the output still does the job. The interface keeps that trade-off explicit instead of turning the result into a promise.