pub struct RateCard { /* private fields */ }Expand description
Published prices, keyed by model identifier.
Deliberately not bundled with Layover. Prices change, they differ per provider and per context tier, and a stale table baked into a release is exactly how a cost estimate drifts by a factor of two without anyone noticing. Whoever runs the factory owns this.
Implementations§
Source§impl RateCard
impl RateCard
Sourcepub fn with(self, model: impl Into<String>, rates: ModelRates) -> Self
pub fn with(self, model: impl Into<String>, rates: ModelRates) -> Self
Adds rates for a model.
Sourcepub fn rates_for(&self, model: &str) -> Option<&ModelRates>
pub fn rates_for(&self, model: &str) -> Option<&ModelRates>
Returns the rates for model, if any are published.
Sourcepub fn estimate(&self, model: &str, usage: TokenUsage) -> Option<f64>
pub fn estimate(&self, model: &str, usage: TokenUsage) -> Option<f64>
Estimates what usage cost on model.
Returns None when the model is unknown or its rates are unusable, which the caller must
treat as CostSource::Unreported rather than as zero.
Sourcepub fn price(
&self,
run: RunId,
itinerary: ItineraryId,
agent: AgentName,
model: Option<String>,
usage: TokenUsage,
) -> RunCost
pub fn price( &self, run: RunId, itinerary: ItineraryId, agent: AgentName, model: Option<String>, usage: TokenUsage, ) -> RunCost
Builds a RunCost for a run that reported tokens but no dollars.
Falls back to CostSource::Unreported — not to a zero that would flatter the totals —
when there is no model, no published rate, or no usage to price.