Expand description
Provider-independent usage accounting primitives.
This crate defines normalized, durable-domain representations for resource consumption at the model-invocation level, including provenance, attribution, and provider-reported monetary amounts. It deliberately has no dependency on model providers, storage engines, HTTP APIs, or monitoring backends.
Pricing data is versioned and cost calculations use integer arithmetic. Storage and run orchestration are owned by the storage and service crates; this crate owns the accounting vocabulary and deterministic calculations.
Structs§
- Cost
Estimate - A reproducible cost calculation in integer currency micro-units.
- Currency
Cost Summary - Cost totals retain the source of every amount.
- Dimension
Usage Summary - Totals for one normalized resource dimension.
- Model
Pricing - Rates are currency micro-units per one million resource units. A missing rate means that the dimension is not priced, not that it is free.
- Reported
Cost - Provider-reported monetary cost, retained separately from calculated cost.
- Usage
Dimensions - Named resource dimensions for one provider invocation.
- Usage
Record - Immutable accounting input for one model invocation.
- Usage
Summary - Run-level totals across all model invocations, retries, and fallbacks.
Enums§
- Cost
Origin - Explains where a monetary amount came from.
- Cost
Status - Invocation
Outcome - Whether the provider invocation completed from the platform’s perspective.
- Metered
Value - A resource quantity together with the provenance of that quantity.
- Pricing
Error - Usage
Record Error
Functions§
- calculate_
cost - Calculates cost using one immutable pricing version. Unknown or unpriced dimensions make the result partial; estimated quantities remain marked.
- summarize_
usage - Aggregates records additively. Each invocation ID is expected to be unique; retries and fallback attempts are separate records and therefore counted.