pub struct ModelPrice {
pub input_per_mtok: f64,
pub output_per_mtok: f64,
pub cache_read_per_mtok: f64,
pub cache_write_5m_per_mtok: f64,
pub cache_write_1h_per_mtok: f64,
pub fast_multiplier: f64,
pub us_only_multiplier: f64,
}Expand description
Per-million-token prices for one model, in US dollars.
Fields§
§input_per_mtok: f64Input (prompt) tokens, dollars per million.
output_per_mtok: f64Output (completion) tokens, dollars per million.
cache_read_per_mtok: f64Prompt tokens read from the cache (a cache hit or refresh), dollars per million.
cache_write_5m_per_mtok: f64Prompt tokens written to the 5-minute cache, dollars per million.
cache_write_1h_per_mtok: f64Prompt tokens written to the 1-hour cache, dollars per million.
fast_multiplier: f64What fast mode (usage.speed: "fast") multiplies every rate by, cache rates included; 1 where the model has
no fast mode (a request asking for it runs, and is billed, at standard speed).
us_only_multiplier: f64What US-only inference (inference_geo: "us") multiplies every rate by: 1.1 on Claude 4.6 and later models,
1 where the model has no such premium.
Implementations§
Source§impl ModelPrice
impl ModelPrice
Sourcepub const fn standard(input_per_mtok: f64, output_per_mtok: f64) -> Self
pub const fn standard(input_per_mtok: f64, output_per_mtok: f64) -> Self
A model priced with the provider’s standard cache multipliers: a cache read at 0.1× input, a 5-minute write at 1.25×, a 1-hour write at 2×, and no fast mode.
Sourcepub fn cost_usd(&self, prompt_tokens: u64, completion_tokens: u64) -> f64
pub fn cost_usd(&self, prompt_tokens: u64, completion_tokens: u64) -> f64
Dollar cost of one round-trip’s token counts.
Cached prompt tokens are billed at the full input rate here: the
provider-reported discount varies per provider and per cache tier,
and over-reporting cost is the safe direction for a cap (a budget
that stops slightly early never overspends). Named rather than
silently assumed — see the per-turn-cost-usage-accounting ledger
row’s note. A recorded session’s spend is Self::recorded_cost_usd.
Sourcepub fn recorded_cost_usd(
&self,
tokens: &RecordedTokens,
fast: bool,
us_only: bool,
) -> f64
pub fn recorded_cost_usd( &self, tokens: &RecordedTokens, fast: bool, us_only: bool, ) -> f64
What a harness’s recorded use cost at these list rates: uncached input, output, cache reads and each cache
write at its own rate (the counts are disjoint, as Claude’s usage reports them), all multiplied in fast mode
and for US-only inference (the multipliers stack).