pub struct PriceTable { /* private fields */ }Expand description
Map of model id to per-million-token rates.
Implementations§
Source§impl PriceTable
impl PriceTable
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Pre-populated with default_pricing_2026_05.
Sourcepub fn insert(
&mut self,
model_id: impl Into<String>,
price: ModelPrice,
) -> &mut Self
pub fn insert( &mut self, model_id: impl Into<String>, price: ModelPrice, ) -> &mut Self
Insert or replace a price entry.
Sourcepub fn get(&self, model_id: &str) -> Option<&ModelPrice>
pub fn get(&self, model_id: &str) -> Option<&ModelPrice>
Lookup, exact match first, then prefix match (e.g. “gpt-4o” matches
“gpt-4o-2024-08-06”). Returns None if no match.
Sourcepub fn compute(&self, model_id: &str, usage: TokenUsage) -> Option<CostDetails>
pub fn compute(&self, model_id: &str, usage: TokenUsage) -> Option<CostDetails>
Compute structured cost from token usage. Returns None when the
model is unknown.
Trait Implementations§
Source§impl Clone for PriceTable
impl Clone for PriceTable
Source§fn clone(&self) -> PriceTable
fn clone(&self) -> PriceTable
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 PriceTable
impl Debug for PriceTable
Source§impl Default for PriceTable
impl Default for PriceTable
Source§fn default() -> PriceTable
fn default() -> PriceTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PriceTable
impl RefUnwindSafe for PriceTable
impl Send for PriceTable
impl Sync for PriceTable
impl Unpin for PriceTable
impl UnsafeUnpin for PriceTable
impl UnwindSafe for PriceTable
Blanket Implementations§
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