compacheCalculator

How the calculator works

The calculator prices one chat workload from token counts and list prices: under a Compache policy fitted to it, under your own rules, and under the documented defaults of other tools. It runs in the browser from site/, with no dependencies, keys, telemetry or provider requests.

It is a model. No model is called, no product is executed and answer quality is not measured. The DocChat benchmark runs the package itself.

Run it

python3 -m http.server 8765 --bind 127.0.0.1 --directory site   # then open http://127.0.0.1:8765/
node --test site/*.test.mjs

From your traces

The package's compache profile command reads recorded threads and prints a link that opens this page with the workload filled in. It can write the same profile to a file. With --policy it carries a fitted policy too. A chat log dropped on the page is measured the same way, with the observed distributions. The page then shows where the numbers came from.

Filled in from tracesSettings
Tokens per turnQuestion, answer and retrieved tokens (median and 95th percentile), the share of turns that retrieve, reasoning tokens, system prompt and tools
Thread lengthMedian and 95th percentile of turns, or the chance of another turn after the first turn and in long threads, whichever describes the threads better
Return delayMedian and 95th percentile of the time between an answer and the next question, how much longer the first return takes, and the share and length of long breaks
One turnHow long an answer takes, model calls per turn, and how often another thread had the system prompt cached
What later turns needPer kind of earlier text: the chance a turn needs it, and how many turns back it lies (median and 95th percentile)
ModelA preset, or the model's own prices, context window and cache rules

Everything else keeps its default and can be edited under Prices and settings.

Workload

After turn n of a thread, with h the turns to halfway of each effect:

chance of another turn = long - (long - first) × 0.5^((n - 1) / h)
median return delay    = median × factor^(0.5^((n - 1) / h))

The defaults for what later turns need were measured on DocChat, where a model answered every turn again with parts of the history withheld:

Earlier textChance per turnTurns back, median95th percentile
Questions15%120
Retrieved text15%330
Answers20%135

The other workload defaults (25,000 retrieved tokens per turn, 8-turn threads, a four-minute return) are assumptions, not measurements.

Prices and cache

Every request is a sequence of blocks with fixed identities and sizes. For each call, with rates per million tokens:

fresh = input - cached
cost  = fresh  × input_rate × cache_write × long_input  / 1,000,000
      + cached × cache_read_rate          × long_input  / 1,000,000
      + output × output_rate              × long_output / 1,000,000

Presets hold list prices in US dollars per million tokens, checked against the provider pages on 20 November 2026. The package's price sheet carries the same numbers, and a test fails when the two differ.

PresetInputCache readOutputCacheLong requests
Claude Fable 5.280.20405 min, from 512 tokensNone
Claude Opus 5.540.20205 min, from 512 tokensNone
Claude Sonnet 5.520.10105 min, from 512 tokensNone
Claude Haiku 5.50.100.010.505 min, from 512 tokensAbove 100k: 5× every rate
GPT-6 Astra1015030 min, from 1,024 tokensAbove 272k: 2× input and cache, 1.5× output
GPT-5.6 Terra20.201230 min, from 1,024 tokensAbove 272k: 2× input and cache, 1.5× output
GPT-6 Luna0.100.010.5030 min, from 1,024 tokensAbove 272k: 2× input and cache, 1.5× output

A cache write costs 1.25× the input price for every preset. Claude presets use a 1,000,000-token window. OpenAI presets use a 1,050,000-token window with at most 922,000 input tokens. Editing a price or a cache rule switches the model to custom prices. Prices exclude tax, regional premiums and batch discounts.

The Compache side

A policy is what compache fit writes: how many turns of questions, of answers and of retrieved text stay, and the most pings while a user is away. A part outside its window is archived when a cut is made, and leaves a notice (28 tokens for a part). A part no larger than its notice stays.

With F the share of returning users back within a delay at that position, d the answer time and the interval one lifetime less the lead, both counted from when the request was sent:

back before ping n       = F(n × interval - d)
cache alive with n pings = F(n × interval + lifetime - d)

Not modeled: keeping retrieved text that matches the question, cited sources, and what the package learns from a ping's own usage.

The comparisons

Every comparison is a set of the same rules, and any of them can be copied into Your app today and edited: the cache lifetime (standard, long or none), the earlier turns sent, retrieved text dropped after some turns or shrunk on arrival, old tool results cleared, older turns summarized, and pings after every answer.

Reading the page

Limits

Sources