#[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<Map<String, Value>>,
}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 completed session work.
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.
output_tokens: u64Total output tokens.
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<Map<String, Value>>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
Sourcepub fn new(total_tokens: u64, input_tokens: u64, output_tokens: u64) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn new(total_tokens: u64, input_tokens: u64, output_tokens: u64) -> Usage
unstable_end_turn_token_usage only.Builds Usage with the required fields set; optional fields start unset or empty.
Sourcepub fn thought_tokens(self, thought_tokens: impl IntoOption<u64>) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn thought_tokens(self, thought_tokens: impl IntoOption<u64>) -> Usage
unstable_end_turn_token_usage only.Total thought/reasoning tokens
Sourcepub fn cached_read_tokens(
self,
cached_read_tokens: impl IntoOption<u64>,
) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn cached_read_tokens( self, cached_read_tokens: impl IntoOption<u64>, ) -> Usage
unstable_end_turn_token_usage only.Total cache read tokens.
Sourcepub fn cached_write_tokens(
self,
cached_write_tokens: impl IntoOption<u64>,
) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn cached_write_tokens( self, cached_write_tokens: impl IntoOption<u64>, ) -> Usage
unstable_end_turn_token_usage only.Total cache write tokens.
Sourcepub fn meta(self, meta: impl IntoOption<Map<String, Value>>) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn meta(self, meta: impl IntoOption<Map<String, Value>>) -> Usage
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<Usage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Usage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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>
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 moreSource§impl Serialize for Usage
impl Serialize for Usage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
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.