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
- Share copies a link that carries every setting. Links made by earlier versions still open, with a note that their numbers were computed differently.
- Export downloads the settings, the sampled threads, every priced call, every candidate policy and the limits below.
- Your data opens a chat log, its labels, a
policy.json, a profile or a file exported here, several at once if you like. You can also drop them on the page. They are read in the browser and sent nowhere. - A setting that is unknown or out of range is reported on the page. Nothing falls back to a default unnoticed.
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 traces | Settings |
|---|---|
| Tokens per turn | Question, answer and retrieved tokens (median and 95th percentile), the share of turns that retrieve, reasoning tokens, system prompt and tools |
| Thread length | Median 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 delay | Median 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 turn | How long an answer takes, model calls per turn, and how often another thread had the system prompt cached |
| What later turns need | Per kind of earlier text: the chance a turn needs it, and how many turns back it lies (median and 95th percentile) |
| Model | A 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
- Two sets of threads. One seed draws the threads the policy is fitted on. The next seed draws the threads both sides are costed on. 100 threads each by default.
- Thread length is lognormal (median and 95th percentile), fixed, or geometric (mean), capped at 160 turns. Before every further turn the thread continues with a set chance.
- By chance of another turn is a fourth way to set the length, for traffic with many one-turn threads and long threads that keep going. The chance moves from its value after the first turn to its value in long threads, and is halfway after a set number of turns.
- Each turn adds a question, retrieved text and an answer. Retrieved tokens are lognormal. A set share of turns retrieves, and the others add a question and an answer only. Zero retrieved tokens means no retrieval at all. The system prompt and tools start every request.
- Return delay is lognormal. Its median and 95th percentile describe long threads. After the first turn the delay is a set multiple of that, and it moves to the long-thread value as the thread goes on. A set share of returns are long breaks instead, whatever the turn: lognormal around their own median, with a 95th percentile four times that. A user who does not return is a thread that ended, not a long delay.
- Answer time. The next question arrives one answer time plus the return delay after the request was sent.
- What later turns need. For questions, retrieved text and answers separately, a turn needs one earlier item of that kind with a set chance. How far back it lies is lognormal with a median and a 95th percentile, rounded to a whole turn, at least one, and limited to the turns that exist. A 95th percentile equal to the median means exactly that many turns back. Retrieved text can only be needed from a turn that retrieved: the distances are weighted over those turns, and before any turn has retrieved there is no such need.
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 text | Chance per turn | Turns back, median | 95th percentile |
|---|---|---|---|
| Questions | 15% | 1 | 20 |
| Retrieved text | 15% | 3 | 30 |
| Answers | 20% | 1 | 35 |
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
- Cached is the longest start a request shares with an earlier request of the same thread that has not expired, in whole cache blocks and at least the model's minimum. An entry lives exactly the configured lifetime from when the request that wrote or read it was sent.
- A shared system prompt. A request that finds less of its own thread cached than the system block reads that block with a set chance: another conversation with the same prompt has cached it. The block must reach the cache minimum. The chance is 0 by default, and OpenClaw's flush and summary prompts are never shared.
- A live entry is read for a set share, all of it by default. This and the shared prompt are priced at the expected tokens read. No outcome is drawn.
- Further calls. A turn that makes more than one model call sends its request again for each further call, with no output: read from the cache where the request can be cached, at the plain input price otherwise. Both sides pay it.
- Reasoning is billed as output with each answer and is not sent again.
- A request below the cache minimum pays the plain input price for its fresh tokens.
- The long-request rates apply to the whole request once its input exceeds the threshold. Zero turns them off.
- An answer enters the cache only when a later request carries it.
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.
| Preset | Input | Cache read | Output | Cache | Long requests |
|---|---|---|---|---|---|
| Claude Fable 5.2 | 8 | 0.20 | 40 | 5 min, from 512 tokens | None |
| Claude Opus 5.5 | 4 | 0.20 | 20 | 5 min, from 512 tokens | None |
| Claude Sonnet 5.5 | 2 | 0.10 | 10 | 5 min, from 512 tokens | None |
| Claude Haiku 5.5 | 0.10 | 0.01 | 0.50 | 5 min, from 512 tokens | Above 100k: 5× every rate |
| GPT-6 Astra | 10 | 1 | 50 | 30 min, from 1,024 tokens | Above 272k: 2× input and cache, 1.5× output |
| GPT-5.6 Terra | 2 | 0.20 | 12 | 30 min, from 1,024 tokens | Above 272k: 2× input and cache, 1.5× output |
| GPT-6 Luna | 0.10 | 0.01 | 0.50 | 30 min, from 1,024 tokens | Above 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.
- Candidates. Windows of 0, 1, 2, 5, 10 and so on turns, all turns, and the look-backs that cover 80% to 97.5% of a kind's needs. Every combination is scored by what it leaves in view and how much of the history it keeps. At most six on the frontier are priced, each keeping at least a point more in view than every smaller one and at least the chosen floor, with 0, 1 and 3 pings and, on Claude, with the standard and the long cache. Keeping everything is always priced too.
- Before a request it compares sending the history as it is with cutting it now: the expected cost of this turn and the next two, over the chance and the delay of a return at that position, with the mean size of a turn. A later cut is allowed for when the history is kept.
- After an answer it compares 0 to the policy's most pings in the same way, every ping paid for until the expected return.
- Fetching back. A turn that needs an archived part pays one extra call that reads the request and returns a short reply (32 tokens by default). The answer call then carries the part. It is not kept afterwards.
- The choice. The cheapest candidate on the fitted threads. Among equally cheap ones, the one with more in view, then with the standard cache, then with fewer pings. Every side is costed on the second set of threads.
- Admission. A request must fit the model's input limit and leave the reserve free (32,000 tokens by default). A side that does not fit has no cost.
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.
- Dropped and cleared text is fetched again with one extra call only where the tool would do so. Otherwise a turn that needs it goes without: the “missing” column. A summary may still carry a fact. That is not evaluated, so summarized text counts as missing.
- A summary call reads the request from the cache, or a bounded digest of the older turns. OpenClaw's uses a digest of at most 40,000 tokens with 500 per tool result, writes 4,000 tokens after a 256-token flush and appends a 1,500-token record.
- OpenClaw follows its documented defaults at revision
c49b553. opencode, Anthropic's context editing and compaction, and Headroom follow their documentation, read on 24 November 2026. The sources and what is assumed are listed under other tools compared. - OpenAI's compaction has no documented default threshold and is not modeled. OpenClaw's own default for OpenAI models calls it. The client-side summary stands in.
- What you pay now is the number you enter, compared as it is.
Reading the page
- The saving is against the side you pick. The range draws the sampled threads again and takes the 5th and 95th percentile. It does not cover what the model leaves out.
- Drawing. Each input chart shows the distribution in force. Dragging its bars replaces the curve by the drawn weights. Inside a bin, values spread evenly on a log scale. Typing a median or a 95th percentile takes the curve again.
- The policy shows each kind's window over where later turns need that kind. Drag an edge to price a policy of your own.
- One conversation shows a sampled thread. The costs of a turn's choices are per 1,000 such turns, over the turn and the next two.
Limits
- Token counts and list prices are assumptions. A cache entry is taken to live exactly its configured lifetime. Providers may keep it longer or evict it sooner.
- A turn's further calls repeat its first request. Text that a tool loop adds between calls counts as arriving with the question. Answer time is one number for every turn.
- The chance of another turn and the return delay depend on a turn's position. What a turn retrieves and what it needs do not.
- Both sides know which earlier sources a turn needs. Real requests have to find that out.
- Needs are independent draws per kind. A real thread has structure this does not capture.
- The policy is the cheapest of a finite set of candidates, not the package's fitted policy. It removes whole retrieved blocks.
- Pings can raise the realized cost: the planner decides on expectations.
- OpenClaw's summary quality, retries, memory tools and its OpenAI compaction path are not modeled.
Sources
- Anthropic pricing, model limits and prompt caching
- OpenAI prompt caching and the model pages linked in the table
- OpenClaw at the pinned revision: compaction thresholds and reserves, summarizer input and record, recent-tail cut point, memory flush, tool-result clearing, Anthropic provider defaults and cache retention