pub struct AiUsage {
pub model: String,
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub total_tokens: u32,
}Expand description
Token accounting for one completed AI API call.
The canonical usage payload for the Reporter::ai_usage channel.
services::ai::AiUsageStats is a legacy alias of this type.
§Examples
use subx_core::core::report::AiUsage;
let usage = AiUsage {
model: "gpt-4.1-mini".to_string(),
prompt_tokens: 120,
completion_tokens: 45,
total_tokens: 165,
};
assert_eq!(usage.prompt_tokens + usage.completion_tokens, usage.total_tokens);Fields§
§model: StringModel identifier reported by the provider.
prompt_tokens: u32Tokens billed for the prompt.
completion_tokens: u32Tokens billed for the completion.
total_tokens: u32Total tokens billed for the call.
Trait Implementations§
impl Eq for AiUsage
impl StructuralPartialEq for AiUsage
Auto Trait Implementations§
impl Freeze for AiUsage
impl RefUnwindSafe for AiUsage
impl Send for AiUsage
impl Sync for AiUsage
impl Unpin for AiUsage
impl UnsafeUnpin for AiUsage
impl UnwindSafe for AiUsage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§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
Compare self to
key and return true if they are equal.