Skip to main content

Function: tokenPricing()

tokenPricing(rates): PriceStep

Defined in: packages/core/src/utils/spend.ts:59

A PriceStep from a rate table keyed by model id (the provider-raw id, e.g. claude-sonnet-5-5; a provider/ or provider: prefix on either side is ignored). A step's id is the one the provider answered with, which is usually a dated snapshot (gpt-4o-2024-08-06): an id the table does not list is priced at its undated base's rates. Four terms, no token counted twice: fresh input, cache writes, cache reads, output. Unknown models return undefined.

Parameters​

rates​

Readonly<Record<string, TokenRates>>

Returns​

PriceStep