pub struct Usage {
pub input_tokens: u32,
pub output_tokens: u32,
pub prompt_cache_hit_tokens: Option<u32>,
pub prompt_cache_miss_tokens: Option<u32>,
pub prompt_cache_write_tokens: Option<u32>,
pub reasoning_tokens: Option<u32>,
pub input_audio_tokens: Option<u32>,
pub output_audio_tokens: Option<u32>,
pub request_usages: Vec<Usage>,
pub reasoning_replay_tokens: Option<u32>,
pub server_tool_use: Option<ServerToolUsage>,
}Expand description
Token usage metadata for a response.
Fields§
§input_tokens: u32§output_tokens: u32§prompt_cache_hit_tokens: Option<u32>§prompt_cache_miss_tokens: Option<u32>§prompt_cache_write_tokens: Option<u32>Cache-creation / cache-write tokens (Anthropic cache_creation_input_tokens).
Billed at the cache-write rate when the pricing row publishes one (#4318).
reasoning_tokens: Option<u32>§input_audio_tokens: Option<u32>§output_audio_tokens: Option<u32>§request_usages: Vec<Usage>§reasoning_replay_tokens: Option<u32>Approximate input tokens spent re-sending prior reasoning_content
across user-message boundaries in DeepSeek V4 thinking-mode tool-calling
turns (V4 §5.1.1 “Interleaved Thinking”). Estimated client-side at
~4 chars/token from the outgoing request body, before the model sees it.
server_tool_use: Option<ServerToolUsage>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
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
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§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.