pub struct PriceTable { /* private fields */ }Expand description
A lookup from provider/model to ModelPrice.
ponytail: the embedded PriceTable::defaults are a calibration knob, not gospel —
list prices drift and enterprise contracts differ. In prod, load overrides from config
via PriceTable::with_override; the defaults just make the common case work out of the box.
Implementations§
Source§impl PriceTable
impl PriceTable
Sourcepub fn defaults() -> Self
pub fn defaults() -> Self
Built-in prices for the common frontier models (USD / 1M tokens, approximate list prices — a starting point to be overridden per deployment).
Sourcepub fn with_override(self, model: impl Into<String>, price: ModelPrice) -> Self
pub fn with_override(self, model: impl Into<String>, price: ModelPrice) -> Self
Insert or replace a model’s price, returning self for chaining.
Sourcepub fn get(&self, model: &str) -> Option<ModelPrice>
pub fn get(&self, model: &str) -> Option<ModelPrice>
Look up a model’s price by its provider/model key.
Sourcepub fn cost_usd(&self, model: &str, input: u64, output: u64) -> Result<f64>
pub fn cost_usd(&self, model: &str, input: u64, output: u64) -> Result<f64>
Cost in USD of a call to model with the given token counts.
§Errors
Returns Error::UnknownModel if the model has no price entry.
Sourcepub fn baseline_usd(
&self,
top_model: &str,
input: u64,
output: u64,
) -> Result<f64>
pub fn baseline_usd( &self, top_model: &str, input: u64, output: u64, ) -> Result<f64>
The counterfactual baseline: what the request would have cost had it gone straight to
top_model (the ladder’s top rung) with the served token counts.
This is an estimate — the top model might have emitted a different number of tokens — but token counts of served output are the fair, auditable proxy the trace records.
§Errors
Returns Error::UnknownModel if top_model has no price entry.
Trait Implementations§
Source§impl Clone for PriceTable
impl Clone for PriceTable
Source§fn clone(&self) -> PriceTable
fn clone(&self) -> PriceTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more