Struct Usage Copy item path Source pub struct Usage {
pub input_tokens: u32 ,
pub output_tokens: u32 ,
pub total_tokens: u32 ,
}Expand description Token usage statistics for a single LLM call.
This is the canonical usage type for the entire workspace. It stores
token counts as u32 (token counts are never negative). The fields
use the clawft naming convention (input_tokens, output_tokens),
but serde aliases allow deserialization from the OpenAI naming
convention (prompt_tokens, completion_tokens) as well.
Tokens consumed by the prompt / input.
Deserializes from either "input_tokens" or "prompt_tokens".
Tokens generated in the response.
Deserializes from either "output_tokens" or "completion_tokens".
Total tokens used (input + output).
When deserializing from providers that include total_tokens, this
field is populated directly. Otherwise it defaults to 0 and callers
can use Usage::total to compute it.
Returns the total token count.
If total_tokens was populated by the provider, returns that value.
Otherwise computes input_tokens + output_tokens.
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Returns the “default value” for a type.
Read more Deserialize this value from the given Serde deserializer.
Read more Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Serialize this value into the given Serde serializer.
Read more Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.