Token billing explained: input, output and cache
Token cost depends on separately priced usage categories, not just the length of the visible answer. Count ordinary input, output and any cache categories according to the actual model’s billing rules.
What is a token?
A token is a unit produced by a model’s tokenizer. Words, punctuation, code and non-English text tokenize differently; there is no reliable universal word-to-token ratio. System instructions, conversation history and tool descriptions can all add input tokens. Visible text alone may omit reasoning or other billed categories.
Use the API usage fields and your billing portal for reconciliation. A local tokenizer is an estimate unless it matches the model and full request format.
Input, output and cached input
| Category | Meaning | What to confirm |
|---|---|---|
| Input | Content supplied to the model | Whether a published input total includes cache hits |
| Output | Generated tokens | Whether reasoning tokens are included or separately itemized |
| Cache read | Reused eligible prompt content | Eligibility and the applicable read rate |
| Cache write | Creating a reusable prompt cache | Whether separately billed and which duration applies |
Cache support and accounting vary by model and provider. A repeated prompt is not automatically a cache hit. Do not subtract cached tokens twice or apply a cache discount to the whole request.
A worked estimate
Illustrative rates only: input $2/M tokens and output $8/M tokens. A request with 10,000 ordinary input tokens and 2,000 output tokens costs 0.01 × $2 + 0.002 × $8 = $0.036, before any other applicable categories. These are not Run7 quotations.
For separately billed categories, estimate cost as the sum of each category’s token count divided by one million and multiplied by that category’s rate. Image, audio, search and long-context surcharges may use other units. Check the model price reference and confirm your effective rates before purchase.
Keep a useful budget record
- Record model ID, usage fields, currency, rate date and request ID without storing credentials.
- Reconcile a small controlled batch before scaling up. Account-credit units are not necessarily dollars.
- Include bounded retries in the budget; a timeout does not prove a request was not processed.
- Reduce unnecessary history and output length before seeking more concurrency.
Keep learning
Sources and scope
Based on public protocol references. Delivered model permissions, rates and capabilities govern actual use. This is not a compatibility guarantee for every client version.
Get an API key ↗