pub struct Usage {
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
}Expand description
Token usage for one conversation.
Field names match the OpenAI wire format; total_tokens follows the
vendor’s convention (not necessarily the sum of the other two). Default
= all zeros.
Presence is carried by the enclosing type: ChatResponse::usage /
StreamEvent::Done::usage are Option<Usage> — None means the
endpoint did not report usage for this turn, Some means the reported
values. The distinction matters for observability: “not reported” is not
the same as “reportedly zero” (the Agent layer also tracks it in
RunSummary::usage_omitted).
Fields§
§prompt_tokens: u32Input tokens for this turn.
completion_tokens: u32Output tokens for this turn.
total_tokens: u32Total for this turn (vendor convention).
Implementations§
Trait Implementations§
Source§impl AddAssign for Usage
Usage accumulates per turn (the Agent layer sums tokens across turns).
impl AddAssign for Usage
Usage accumulates per turn (the Agent layer sums tokens across turns).
Source§fn add_assign(&mut self, rhs: Usage)
fn add_assign(&mut self, rhs: Usage)
Performs the
+= operation. Read moreimpl Copy for Usage
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Usage
Source§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,
Serialize this value into the given Serde serializer. Read more
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.