pub struct Pricing {
pub input: Option<PricePoint>,
pub output: Option<PricePoint>,
pub cached_input: Option<PricePoint>,
pub cache_write: Option<PricePoint>,
pub reasoning: Option<PricePoint>,
pub notes: Option<&'static str>,
}Fields§
§input: Option<PricePoint>§output: Option<PricePoint>§cached_input: Option<PricePoint>Rate for input tokens served from cache (cache_read).
cache_write: Option<PricePoint>Rate for input tokens written INTO the cache (cache_write).
Providers charge a premium for a cache write — Anthropic’s is 1.25× the
ordinary input rate — so a source that publishes one prices those
tokens with it. None means the source does not publish one, and
cache-creation tokens then bill at the ordinary input rate, which is a
bounded under-estimate of what the provider actually charges.
reasoning: Option<PricePoint>Rate a source publishes for reasoning/thinking tokens, when it differs from the output rate.
Reasoning tokens ride inside the output-token count — no Usage
field splits them out — so they cannot be billed separately. Output is
therefore billed at max(output, reasoning): on the many rows where
reasoning is cheaper this is the output rate (unchanged), and on the
rows where reasoning is dearer (e.g. alibaba/qwen3-32b: output $2.80/M,
reasoning $8.40/M) it lifts the whole output band to the reasoning rate,
so the estimate is never below what the reasoning tokens actually cost.
The exact split needs a reasoning component on Usage; see the PR
residual.
notes: Option<&'static str>Implementations§
Source§impl Pricing
impl Pricing
pub const fn flat(input: f64, output: f64) -> Pricing
pub const fn flat_with_cached( input: f64, output: f64, cached_input: f64, ) -> Pricing
Sourcepub const fn with_cache_write(self, cache_write: f64) -> Pricing
pub const fn with_cache_write(self, cache_write: f64) -> Pricing
Builder-style: attach the cache-write (cache_write) rate.
Sourcepub const fn with_reasoning(self, reasoning: f64) -> Pricing
pub const fn with_reasoning(self, reasoning: f64) -> Pricing
Builder-style: attach the reasoning-token rate.