pub struct ModelCosts {
pub input_tokens: f64,
pub output_tokens: f64,
pub prompt_cache_write_tokens: f64,
pub prompt_cache_read_tokens: f64,
pub web_search_requests: f64,
}Expand description
Model cost configuration (per million tokens)
Fields§
§input_tokens: f64Input tokens cost per million
output_tokens: f64Output tokens cost per million
prompt_cache_write_tokens: f64Prompt cache write tokens cost per million
prompt_cache_read_tokens: f64Prompt cache read tokens cost per million
web_search_requests: f64Web search requests cost per search
Implementations§
Source§impl ModelCosts
impl ModelCosts
Sourcepub fn input_cost(&self, tokens: u32) -> f64
pub fn input_cost(&self, tokens: u32) -> f64
Calculate cost for input tokens
Sourcepub fn output_cost(&self, tokens: u32) -> f64
pub fn output_cost(&self, tokens: u32) -> f64
Calculate cost for output tokens
Sourcepub fn cache_write_cost(&self, tokens: u32) -> f64
pub fn cache_write_cost(&self, tokens: u32) -> f64
Calculate cost for cache write tokens
Sourcepub fn cache_read_cost(&self, tokens: u32) -> f64
pub fn cache_read_cost(&self, tokens: u32) -> f64
Calculate cost for cache read tokens
Sourcepub fn total_cost(&self, usage: &TokenUsage) -> f64
pub fn total_cost(&self, usage: &TokenUsage) -> f64
Calculate total cost for a usage record
Trait Implementations§
Source§impl Clone for ModelCosts
impl Clone for ModelCosts
Source§fn clone(&self) -> ModelCosts
fn clone(&self) -> ModelCosts
Returns a duplicate of the value. Read more
1.0.0 · 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 ModelCosts
impl Debug for ModelCosts
Source§impl<'de> Deserialize<'de> for ModelCosts
impl<'de> Deserialize<'de> for ModelCosts
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
Auto Trait Implementations§
impl Freeze for ModelCosts
impl RefUnwindSafe for ModelCosts
impl Send for ModelCosts
impl Sync for ModelCosts
impl Unpin for ModelCosts
impl UnsafeUnpin for ModelCosts
impl UnwindSafe for ModelCosts
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