A Clear Token Ledger Makes Every Charge Explainable
A token total is a measurement, not a complete bill. Two requests with similar totals can cost different amounts because fresh input, generated output, cache reads, and cache writes may carry different rates. A transparent ledger preserves those distinctions and explains the arithmetic connecting provider usage to the amount deducted.
This walkthrough follows that process at BestRelay, a quality-first API relay that forwards each request to the official model named in it, without substitution. Its coverage includes Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok, and more. Billing is pay-as-you-go, based on the token counts the provider reports.
Step one ties usage to the actual request
Start with the request record: the requested model, timestamp, request identifier when available, and completion status. These fields establish the context for the usage figures. A model name is not itself a usage measurement, but it determines which pricing schedule should apply.
BestRelay works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK. Regardless of the client, distinguish a single provider request from a complete user task. An agent may make several requests while completing one instruction, so one visible task can produce multiple billing entries.
Step two separates fresh input from generated output
Input tokens measure material sent into the model, subject to the provider's accounting rules. That can include instructions, conversation history, tool definitions, and tool results, rather than just the latest message. A short question inside a long conversation can therefore have substantial input usage.
Output tokens measure generated material under the provider's definition. Do not assume this count always matches the text displayed in the client. Some providers include reasoning or other generated token categories within output accounting. Detail fields may explain a larger count without representing additional charges to add again.
Step three gives cache activity its own categories
Cache-read tokens represent input served through an eligible provider cache. Cache-write tokens represent input recorded through a billable cache-creation mechanism. BestRelay prices cache reads and writes separately, so neither category should automatically receive the ordinary input rate.
The critical detail is whether a cache count is included in another field. Some provider formats report cached tokens as a subset of input; others expose ordinary input and cache activity separately. Subtract cached tokens only when the provider's definition requires it. Otherwise, subtraction can undercount usage, while adding overlapping fields can double-count it.
Step four checks totals without inventing billable categories
Total tokens is generally a reconciliation aid, not a separate item to charge after input and output. Check its definition before expecting it to equal the sum of every displayed detail field. Nested breakdowns often overlap with their parent counts.
Likewise, reasoning, audio, image, or other detail fields require provider-specific interpretation. A missing field does not prove zero usage, and an unavailable measurement should not silently become a confident estimate. For streaming requests, check for final usage reporting rather than treating an early, incomplete response as the finished record.
Step five applies rates to nonoverlapping token buckets
Once the categories are understood, multiply each billable bucket by its applicable rate and normalize for the quoted pricing unit. Keep fresh input, output, cache reads, and cache writes distinct wherever the provider's accounting supports those distinctions.
For example, if an input count includes cache reads, separate those reads before pricing the remaining fresh input. If cache reads are already reported outside ordinary input, do not subtract them again. Retain enough precision during calculation to explain any final rounding.
Step six keeps account movements separate from consumption
A top-up adds funds; a usage charge consumes them. Those entries explain balance changes but are not token fields. BestRelay members also earn a referral commission when people they invite top up. That commission belongs in the account ledger, separate from provider-reported model usage.
Create a BestRelay account to get started.
The final check is straightforward: every charge should connect a request, an interpretable usage category, and an applicable rate, without counting the same tokens twice.
Want to try the models discussed here? Sign up