pub struct UsageRecord {
pub invocation_id: Uuid,
pub run_id: Uuid,
pub iteration: u32,
pub agent: String,
pub principal_id: Option<String>,
pub provider: String,
pub model: String,
pub outcome: InvocationOutcome,
pub usage: UsageDimensions,
pub reported_cost: Option<ReportedCost>,
pub occurred_at: DateTime<Utc>,
}Expand description
Immutable accounting input for one model invocation.
Every retry/fallback attempt has its own invocation ID. This makes usage aggregation additive and prevents a successful retry from hiding a billable failed attempt.
Fields§
§invocation_id: Uuid§run_id: Uuid§iteration: u32§agent: String§principal_id: Option<String>§provider: String§model: String§outcome: InvocationOutcome§usage: UsageDimensions§reported_cost: Option<ReportedCost>§occurred_at: DateTime<Utc>Implementations§
Source§impl UsageRecord
impl UsageRecord
pub fn new( invocation_id: Uuid, run_id: Uuid, iteration: u32, agent: impl Into<String>, principal_id: Option<String>, provider: impl Into<String>, model: impl Into<String>, outcome: InvocationOutcome, usage: UsageDimensions, occurred_at: DateTime<Utc>, ) -> Result<Self, UsageRecordError>
pub fn with_reported_cost(self, cost: ReportedCost) -> Self
Trait Implementations§
Source§impl Clone for UsageRecord
impl Clone for UsageRecord
Source§impl Debug for UsageRecord
impl Debug for UsageRecord
Source§impl<'de> Deserialize<'de> for UsageRecord
impl<'de> Deserialize<'de> for UsageRecord
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 UsageRecord
Source§impl PartialEq for UsageRecord
impl PartialEq for UsageRecord
Source§impl Serialize for UsageRecord
impl Serialize for UsageRecord
impl StructuralPartialEq for UsageRecord
Auto Trait Implementations§
impl Freeze for UsageRecord
impl RefUnwindSafe for UsageRecord
impl Send for UsageRecord
impl Sync for UsageRecord
impl Unpin for UsageRecord
impl UnsafeUnpin for UsageRecord
impl UnwindSafe for UsageRecord
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