pub struct ModelPricing {
pub name: &'static str,
pub input_per_mtok: f64,
pub output_per_mtok: f64,
pub cache_write_per_mtok: f64,
pub cache_read_per_mtok: f64,
}Expand description
Model pricing information (per million tokens).
Fields§
§name: &'static strHuman-readable model name (e.g. "Claude Sonnet 4.5").
input_per_mtok: f64Cost in USD per million input tokens.
output_per_mtok: f64Cost in USD per million output tokens.
cache_write_per_mtok: f64Cost in USD per million tokens written to the prompt cache.
cache_read_per_mtok: f64Cost in USD per million tokens read from the prompt cache.
Implementations§
Source§impl ModelPricing
impl ModelPricing
Sourcepub const SONNET_4_5: ModelPricing
pub const SONNET_4_5: ModelPricing
Anthropic Claude pricing (as of Feb 2026).
pub const SONNET_3_7: ModelPricing
pub const SONNET_3_5: ModelPricing
pub const SONNET_3: ModelPricing
pub const OPUS_4_5: ModelPricing
pub const OPUS_3: ModelPricing
pub const HAIKU_4_5: ModelPricing
pub const HAIKU_3_5: ModelPricing
pub const HAIKU_3: ModelPricing
Sourcepub fn from_model_str(model: &str) -> Option<&'static ModelPricing>
pub fn from_model_str(model: &str) -> Option<&'static ModelPricing>
Look up pricing from a model identifier string (e.g. "claude-opus-4-6").
Matching is case-insensitive and uses substring search on the model
identifier. The family (opus, sonnet, haiku) is detected first,
then the version number within that family. Returns None for unknown
model identifiers.
Sourcepub fn calculate_turn_cost(&self, usage: &TokenUsage) -> f64
pub fn calculate_turn_cost(&self, usage: &TokenUsage) -> f64
Calculate cost for a single turn’s token usage.
Sourcepub fn calculate_cost(&self, stats: &TokenStats) -> CostBreakdown
pub fn calculate_cost(&self, stats: &TokenStats) -> CostBreakdown
Calculate cost for given token usage.
Trait Implementations§
Source§impl Clone for ModelPricing
impl Clone for ModelPricing
Source§fn clone(&self) -> ModelPricing
fn clone(&self) -> ModelPricing
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelPricing
impl Debug for ModelPricing
impl Copy for ModelPricing
Auto Trait Implementations§
impl Freeze for ModelPricing
impl RefUnwindSafe for ModelPricing
impl Send for ModelPricing
impl Sync for ModelPricing
impl Unpin for ModelPricing
impl UnsafeUnpin for ModelPricing
impl UnwindSafe for ModelPricing
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.