pub struct Usage {
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_creation_input_tokens: u64,
pub cache_read_input_tokens: u64,
}Expand description
Four-field token usage as returned by Anthropic API and Bedrock Converse.
Field names match Anthropic’s API; the From impls in this crate map
Bedrock Converse’s camelCase names (cacheReadInputTokens,
cacheWriteInputTokens -> cache_creation_input_tokens) onto these.
Fields§
§input_tokens: u64Tokens in the input prompt that were not cached.
output_tokens: u64Tokens in the model output.
cache_creation_input_tokens: u64Tokens written to the prompt cache on this request (cache miss).
cache_read_input_tokens: u64Tokens served from the prompt cache (cache hit).
Implementations§
Source§impl Usage
impl Usage
Sourcepub fn total_tokens(&self) -> u64
pub fn total_tokens(&self) -> u64
Total tokens billed (input + output + cache_creation + cache_read).
Sourcepub fn from_bedrock_converse(
input_tokens: u64,
output_tokens: u64,
cache_read_input_tokens: u64,
cache_write_input_tokens: u64,
) -> Self
pub fn from_bedrock_converse( input_tokens: u64, output_tokens: u64, cache_read_input_tokens: u64, cache_write_input_tokens: u64, ) -> Self
Build a Usage from Bedrock Converse’s camelCase JSON shape.
The inputTokens field on Bedrock includes only fresh input (cache
fields are reported separately), so we map them 1:1.
Trait Implementations§
impl Copy for Usage
impl Eq for Usage
impl 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