Skip to content

Main content

Prompt Cache Discount One Token Cost Tool

Caller-supplied token pricing and cached share, without a provider price lookup.

Loading tool…

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

  1. Enter tokens, basePerMillion, cachedFraction, cachedPriceFraction. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. 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 fieldMeaning and unitsAccepted input
tokensTokensRequired. Safe integer; minimum 0.
basePerMillionCaller-supplied currency per million uncached tokens.Required. Finite number; minimum 0.
cachedFractionFraction of token quantity receiving cached pricing; fractional estimated counts are allowed.Required. Finite number; minimum 0; maximum 1.
cachedPriceFractionCached price as a fraction of base price, rather than a fraction deducted.Required. Finite number; minimum 0; maximum 1.
Output fieldInterpretationReturned shape
uncachedTokensUncached TokensRequired. Finite number.
cachedTokensCached TokensRequired. Finite number.
totalCostTotal CostRequired. Finite number.
savingsSavingsRequired. Finite number.
json
{
  "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

  1. Calculation and input contract: artificial-intelligence/prompt-cache-discount-one-token-cost — tool.io

Similar or alternative tools