pub struct ModelRates {
pub input_usd: f64,
pub output_usd: f64,
pub cache_read_usd: f64,
pub cache_write_usd: f64,
}Expand description
What one model costs, in US dollars per million tokens.
Four separate rates rather than one, because providers price cached tokens far below fresh input — often ten to one — and a single blended rate is wrong by whatever the cache hit rate happens to be that day.
Fields§
§input_usd: f64Dollars per million prompt tokens.
output_usd: f64Dollars per million generated tokens.
cache_read_usd: f64Dollars per million tokens served from the prompt cache.
cache_write_usd: f64Dollars per million tokens written to the prompt cache.
Implementations§
Source§impl ModelRates
impl ModelRates
Sourcepub fn cost_of(&self, usage: TokenUsage) -> Option<f64>
pub fn cost_of(&self, usage: TokenUsage) -> Option<f64>
Returns the cost of usage, or None if any rate is not a usable number.
A negative or non-finite rate is a configuration mistake, and guessing past it would produce a total that looks authoritative and is not.
Trait Implementations§
Source§impl Clone for ModelRates
impl Clone for ModelRates
impl Copy for ModelRates
Source§impl Debug for ModelRates
impl Debug for ModelRates
Source§impl Default for ModelRates
impl Default for ModelRates
Source§impl<'de> Deserialize<'de> for ModelRates
impl<'de> Deserialize<'de> for ModelRates
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ModelRates
impl PartialEq for ModelRates
Source§impl Serialize for ModelRates
impl Serialize for ModelRates
impl StructuralPartialEq for ModelRates
Auto Trait Implementations§
impl Freeze for ModelRates
impl RefUnwindSafe for ModelRates
impl Send for ModelRates
impl Sync for ModelRates
impl Unpin for ModelRates
impl UnsafeUnpin for ModelRates
impl UnwindSafe for ModelRates
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