pub struct Usage {
pub input_tokens: u64,
pub cached_input_tokens: u64,
pub cache_creation_tokens: u64,
pub output_tokens: u64,
}Fields§
§input_tokens: u64Number of prompt tokens processed during the turn.
cached_input_tokens: u64Number of cached prompt tokens reused from previous turns.
cache_creation_tokens: u64Number of cache-creation tokens charged during the turn.
output_tokens: u64Number of completion tokens generated by the model.
Implementations§
Source§impl Usage
impl Usage
Sourcepub fn uncached_input_tokens(&self) -> u64
pub fn uncached_input_tokens(&self) -> u64
Number of input tokens billed at the full input rate: neither served
from cache nor written to it. input_tokens is the total prompt token
count (uncached + cached + cache-creation), so both cached and
cache-creation tokens are subtracted out here.
Sourcepub fn cache_hit_rate(&self) -> Option<f64>
pub fn cache_hit_rate(&self) -> Option<f64>
Cache hit rate as a fraction (0.0 to 1.0): cached input over total input.
Returns None when no input tokens were recorded.
Sourcepub fn cache_summary(&self) -> String
pub fn cache_summary(&self) -> String
Human-readable summary of prompt cache efficiency.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Usage
impl<'de> Deserialize<'de> for Usage
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
impl Eq for Usage
Source§impl JsonSchema for Usage
impl JsonSchema for Usage
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Usage
Auto Trait Implementations§
impl Freeze for Usage
impl RefUnwindSafe for Usage
impl Send for Usage
impl Sync for Usage
impl Unpin for Usage
impl UnsafeUnpin for Usage
impl UnwindSafe for Usage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.