Reading a Request Bill: Input, Output, Store, Hit
Four token buckets, one request bill
When an editor agent finishes a task, I want more than a balance change. I want to know what entered the model, what came back, and whether the context was written to cache or read from it. Those are separate questions, so my audit keeps four separate buckets.
Fluxo gives that workflow one key and one base URL, https://api.fluxorelay.com, across Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and more. It works with Claude Code, Codex, Gemini CLI and any OpenAI SDK. Billing follows real tokens, including cache reads and writes, without a monthly fee. Here, we will reconcile one request locally rather than guess an undocumented billing endpoint.
1. Separate input from cache accounting
Start with one request's usage record and its applicable rates. For a concrete example, imagine auditing a Claude Haiku 4.5 request. Record the request identifier and timestamp alongside your working files so you can match the calculation to the original charge.
- Input means uncached input tokens in our normalized audit.
- Output means generated tokens recorded in the request usage.
- Cache store means input tokens charged for creating cached context.
- Cache hit means input tokens charged for reading cached context.
These are audit labels, not promised Fluxo response fields. In Anthropic's native accounting, input_tokens excludes cache creation and cache reads; total prompt input adds all three categories. Cache creation and cache reads have separate pricing, while caching does not change output token generation. Verify your response format before mapping its fields into these buckets. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching?cms_guid=false&fcdaa149_sort_date=desc&lang=null&onlycontent=1&utm_source=openai))
2. Create a reproducible billing fixture
Open a POSIX-compatible shell with Python 3 installed. Run these commands in a scratch directory: — mkdir -p fluxo-bill-audit
cd fluxo-bill-audit — The following numbers are deliberately illustrative, not Fluxo prices or measured usage. Rates are currency units per million tokens. Replace every count and rate with the corresponding values from your actual request bill before reconciling money.
printf 'bucket,tokens,rate_per_million\ninput,2000,3\noutput,500,15\ncache_store,8000,3.75\ncache_hit,0,0.30\n' > first.csv
This fixture represents 2,000 uncached input tokens, 500 output tokens, and 8,000 cache-store tokens. Its zero cache-hit count is explicit; it is not a fallback for missing telemetry. If a field is unavailable, investigate rather than silently treating it as zero.
3. Calculate each charge with decimal arithmetic
For each bucket, multiply tokens by its per-million rate, then divide by 1,000,000. This command prints every component and the total, using decimal arithmetic rather than binary floating-point:
python3 -c 'import csv,sys; from decimal import Decimal as D; rows=list(csv.DictReader(open(sys.argv[1], newline=""))); charges=[(r["bucket"],D(r["tokens"])*D(r["rate_per_million"])/D("1000000")) for r in rows]; [print("{}: {:.8f}".format(k,v)) for k,v in charges]; print("total: {:.8f}".format(sum((v for _,v in charges),D("0"))))' first.csv
The expected component charges are 0.00600000, 0.00750000, 0.03000000, and 0.00000000. Their total is 0.04350000. Keep the intermediate precision while checking the arithmetic; compare the result with the bill's stated rounding rules.
4. Compare cache store with cache hit
Now create a second fixture that moves the same 8,000 tokens from cache store to cache hit, holding uncached input and output constant:
printf 'bucket,tokens,rate_per_million\ninput,2000,3\noutput,500,15\ncache_store,0,3.75\ncache_hit,8000,0.30\n' > second.csv
Rerun the Python command with second.csv as its final argument. The total becomes 0.01590000, a difference of 0.02760000. That isolates the effect of our illustrative cache rates; it does not guarantee that repeating a live request produces a cache hit.
For real comparisons, inspect the actual cache counters. Anthropic documents minimum cacheable prompt lengths and separate cache-creation and cache-read usage fields, so a second request alone is not evidence of successful caching. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching?cc61befa_page=2&fcdaa149_page=14&query=spam&utm_source=openai))
5. Keep the bill beside the debugging notes
Before closing the task, check the model, request identifier, token categories, rate units, and any cache-duration pricing tiers. Split differently priced tiers into separate audit rows instead of forcing them into one rate.
If you would like to try this with your own requests, create a Fluxo account and keep your first bill beside the terminal output. Fluxo also shares referral revenue when people you invite pay; keep that separate from request-cost accounting.
Public Fluxo billing documentation could not be verified, so these exact commands operate on an explicitly local audit format, not an assumed API export schema.