pub struct CacheMetrics {
pub run_id: RunId,
pub cache_creation_input_tokens: u64,
pub cache_read_input_tokens: u64,
pub cached_input_tokens: u64,
pub timestamp: DateTime<Utc>,
}Expand description
Emitted after each model call when the provider reported prompt cache statistics. All fields are zero when the provider did not report cache hits or writes for this call.
Fields§
§run_id: RunIdRun identifier.
cache_creation_input_tokens: u64Number of input tokens written to the cache by this call
(Anthropic: cache_creation_input_tokens).
cache_read_input_tokens: u64Number of input tokens served from the cache by this call
(Anthropic: cache_read_input_tokens, DeepSeek: prompt_cache_hit_tokens).
cached_input_tokens: u64Number of input tokens served from the cache by this call
(OpenAI: prompt_tokens_details.cached_tokens).
timestamp: DateTime<Utc>When the metrics were recorded.
Implementations§
Source§impl CacheMetrics
impl CacheMetrics
Sourcepub const fn total_cache_tokens(&self) -> u64
pub const fn total_cache_tokens(&self) -> u64
Returns the total cache-related input tokens.
Trait Implementations§
Source§impl Clone for CacheMetrics
impl Clone for CacheMetrics
Source§fn clone(&self) -> CacheMetrics
fn clone(&self) -> CacheMetrics
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 CacheMetrics
impl Debug for CacheMetrics
Source§impl<'de> Deserialize<'de> for CacheMetrics
impl<'de> Deserialize<'de> for CacheMetrics
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CacheMetrics, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CacheMetrics, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for CacheMetrics
impl Serialize for CacheMetrics
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for CacheMetrics
impl RefUnwindSafe for CacheMetrics
impl Send for CacheMetrics
impl Sync for CacheMetrics
impl Unpin for CacheMetrics
impl UnsafeUnpin for CacheMetrics
impl UnwindSafe for CacheMetrics
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