pub struct PricingConfig {
pub overrides: HashMap<String, ModelRate>,
}Expand description
Pricing configuration stored under [pricing] in newt.toml.
Fields§
§overrides: HashMap<String, ModelRate>Per-model overrides. Keys are exact model-id strings or prefix patterns.
Example: { "my-private-gpt4" = { input_usd_per_1k = 0.01, output_usd_per_1k = 0.03 } }
Implementations§
Source§impl PricingConfig
impl PricingConfig
Sourcepub fn rate_for(&self, model_id: &str) -> Option<ModelRate>
pub fn rate_for(&self, model_id: &str) -> Option<ModelRate>
Look up the rate for model_id.
Resolution order:
- Exact match in
overrides - Prefix match in
overrides(longest prefix wins) - Built-in rate table
None— unknown model; caller should not display a cost
Returns Some(ModelRate { input: 0.0, output: 0.0 }) for known local
models so the display can show “free (local)”.
Sourcepub fn estimate_cost(
&self,
model_id: &str,
usage: Option<&TokenUsage>,
) -> Option<f64>
pub fn estimate_cost( &self, model_id: &str, usage: Option<&TokenUsage>, ) -> Option<f64>
Estimate cost for usage with model_id.
Returns None when the model is unknown (not local, not in table, not overridden).
Trait Implementations§
Source§impl Clone for PricingConfig
impl Clone for PricingConfig
Source§fn clone(&self) -> PricingConfig
fn clone(&self) -> PricingConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PricingConfig
impl Debug for PricingConfig
Source§impl Default for PricingConfig
impl Default for PricingConfig
Source§fn default() -> PricingConfig
fn default() -> PricingConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for PricingConfigwhere
PricingConfig: Default,
impl<'de> Deserialize<'de> for PricingConfigwhere
PricingConfig: Default,
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
Auto Trait Implementations§
impl Freeze for PricingConfig
impl RefUnwindSafe for PricingConfig
impl Send for PricingConfig
impl Sync for PricingConfig
impl Unpin for PricingConfig
impl UnsafeUnpin for PricingConfig
impl UnwindSafe for PricingConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more