pub struct Usage {
pub input_tokens: u32,
pub output_tokens: u32,
pub cache_creation_input_tokens: u32,
pub cache_read_input_tokens: u32,
}Fields§
§input_tokens: u32§output_tokens: u32§cache_creation_input_tokens: u32Tokens written into the prompt cache by this call, and tokens read
back from it. Both are priced differently from ordinary input — a
cache read costs a fraction of one — so a report that folded them
into input_tokens would overcharge and one that dropped them
undercharges by whatever the cache covered.
#[serde(default)] because recordings written before these existed
must still read back.
cache_read_input_tokens: u32Implementations§
Source§impl Usage
impl Usage
Sourcepub fn plus(self, other: Usage) -> Usage
pub fn plus(self, other: Usage) -> Usage
This and one more call’s worth.
A provider reports usage per call and a turn is several calls, so
summing is what anyone asking “what did that cost” has to do. Saturating
because a turn that overflowed a u32 of tokens has a bigger problem
than an inexact total, and wrapping to nearly zero would be the one
answer worse than the true one.
Trait Implementations§
impl Copy for Usage
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 Forget for Usage
impl Freeze for Usage
impl Move 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