#[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>,
pub meta: Option<Meta>,
}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
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.
meta: Option<Meta>The _meta property is reserved by ACP to allow clients and agents to attach additional metadata to their interactions. Implementations MUST NOT make assumptions about values at these keys.
See protocol docs: Extensibility
Implementations§
Source§impl Usage
impl Usage
pub fn new(total_tokens: u64, input_tokens: u64, output_tokens: u64) -> Self
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.
Sourcepub fn meta(self, meta: impl IntoOption<Meta>) -> Self
Available on crate feature unstable_end_turn_token_usage only.
pub fn meta(self, meta: impl IntoOption<Meta>) -> Self
unstable_end_turn_token_usage only.The _meta property is reserved by ACP to allow clients and agents to attach additional metadata to their interactions. Implementations MUST NOT make assumptions about values at these keys.
See protocol docs: Extensibility
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>,
impl Eq for Usage
Source§impl IntoV2 for Usage
Available on crate features unstable_end_turn_token_usage and unstable_protocol_v2 only.
impl IntoV2 for Usage
unstable_end_turn_token_usage and unstable_protocol_v2 only.Source§impl JsonSchema for Usage
impl JsonSchema for Usage
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$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
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
key and return true if they are equal.