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: Self)
fn add_assign(&mut self, rhs: Self)
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<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
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