Description
Return cached/uncached token-cost bookkeeping.
Inference budgets depend on the number of stored values, sequence lengths, routing assignments and the chosen accounting basis. Logical cache bytes and padded token counts differ from actual device allocation, latency and billed usage. Caller-supplied prices, cache fractions and capacity assumptions must match the intended system.
Return cached/uncached token-cost bookkeeping.
When to use this tool
Use Prompt Cache Discount One Token Cost when reconciling the stated cache, padding, routing or price basis.
How to use the tool and how it works
- Enter tokens, basePerMillion, cachedFraction, cachedPriceFraction. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read uncachedTokens, cachedTokens, totalCost, savings. Use the output convention below.
Return cached/uncached token-cost bookkeeping. Require whole tokens >= 0, nonnegative basePerMillion and cached/price fractions in [0,1]; split tokens by cachedFraction, cost weights cached tokens by cachedPriceFraction, savings compares with full price.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| tokens | Tokens | Required. Safe integer; minimum 0. |
| basePerMillion | Caller-supplied currency per million uncached tokens. | Required. Finite number; minimum 0. |
| cachedFraction | Fraction of token quantity receiving cached pricing; fractional estimated counts are allowed. | Required. Finite number; minimum 0; maximum 1. |
| cachedPriceFraction | Cached price as a fraction of base price, rather than a fraction deducted. | Required. Finite number; minimum 0; maximum 1. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| uncachedTokens | Uncached Tokens | Required. Finite number. |
| cachedTokens | Cached Tokens | Required. Finite number. |
| totalCost | Total Cost | Required. Finite number. |
| savings | Savings | Required. Finite number. |
{
"input": {
"tokens": 1000000,
"basePerMillion": 2,
"cachedFraction": 0.5,
"cachedPriceFraction": 0.25
},
"output": {
"uncachedTokens": 500000,
"cachedTokens": 500000,
"totalCost": 1.25,
"savings": 0.75
}
} Limitations and assumptions
- Token shares may be fractional estimates; prices and cache eligibility are supplied rather than verified against a provider or actual invoice.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.
Alternative or Complementary methods
Use actual model/runtime layouts, allocator measurements and current provider billing records for real memory, performance or cost planning.
References
Similar or alternative tools
- Artificial Intelligence: Kv Cache Token Byte Count
Return an exact unpadded key/value-cache byte count.
- Inference Batch Sequence Waste Term
Return ragged-batch token totals and padding waste.