#[non_exhaustive]pub struct Usage {
pub total_tokens: u64,
pub input_tokens: u64,
pub output_tokens: u64,
pub thought_tokens: Option<u64>,
pub cached_read_tokens: Option<u64>,
pub cached_write_tokens: Option<u64>,
}Available on crate feature
unstable_protocol_v2 only.Expand description
UNSTABLE
This capability is not part of the spec yet, and may be removed or changed at any point.
Token usage information for a prompt turn.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.total_tokens: u64Sum of all token types across session.
input_tokens: u64Total input tokens across all turns.
output_tokens: u64Total output tokens across all turns.
thought_tokens: Option<u64>Total thought/reasoning tokens
cached_read_tokens: Option<u64>Total cache read tokens.
cached_write_tokens: Option<u64>Total cache write tokens.
Implementations§
Source§impl Usage
impl Usage
pub fn new(total_tokens: u64, input_tokens: u64, output_tokens: u64) -> Self
Available on crate feature
unstable_end_turn_token_usage only.Sourcepub fn thought_tokens(self, thought_tokens: impl IntoOption<u64>) -> Self
Available on crate feature unstable_end_turn_token_usage only.
pub fn thought_tokens(self, thought_tokens: impl IntoOption<u64>) -> Self
unstable_end_turn_token_usage only.Total thought/reasoning tokens
Sourcepub fn cached_read_tokens(
self,
cached_read_tokens: impl IntoOption<u64>,
) -> Self
Available on crate feature unstable_end_turn_token_usage only.
pub fn cached_read_tokens( self, cached_read_tokens: impl IntoOption<u64>, ) -> Self
unstable_end_turn_token_usage only.Total cache read tokens.
Sourcepub fn cached_write_tokens(
self,
cached_write_tokens: impl IntoOption<u64>,
) -> Self
Available on crate feature unstable_end_turn_token_usage only.
pub fn cached_write_tokens( self, cached_write_tokens: impl IntoOption<u64>, ) -> Self
unstable_end_turn_token_usage only.Total cache write tokens.
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