pub struct Usage {
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
pub cost: Option<f64>,
pub input_tokens_details: Option<InputTokensDetails>,
pub output_tokens_details: Option<OutputTokensDetails>,
}Expand description
Token usage statistics for a completion request.
Tracks the number of tokens consumed by the prompt and completion, along with optional cost information and detailed breakdowns.
§Note
Different providers may count tokens differently. The total_tokens
should always equal prompt_tokens + completion_tokens.
Fields§
§prompt_tokens: u32Number of tokens in the input prompt.
completion_tokens: u32Number of tokens generated in the completion.
total_tokens: u32Total tokens used (prompt + completion).
cost: Option<f64>Estimated cost in USD for this request (if available).
input_tokens_details: Option<InputTokensDetails>Detailed breakdown of input token usage.
output_tokens_details: Option<OutputTokensDetails>Detailed breakdown of output token usage.
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>,
Deserialize this value from the given Serde deserializer. Read more
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
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