pub struct PricingResolver { /* private fields */ }Expand description
Ordered model pricing lookup chain.
Implementations§
Source§impl PricingResolver
impl PricingResolver
Sourcepub fn from_catalogs(catalogs: Vec<PricingCatalog>) -> Self
pub fn from_catalogs(catalogs: Vec<PricingCatalog>) -> Self
Builds a resolver from already-loaded catalogs in precedence order.
Sourcepub fn from_config(config: &PricingConfig) -> Result<Self, PricingCatalogError>
pub fn from_config(config: &PricingConfig) -> Result<Self, PricingCatalogError>
Builds a resolver from declarative config.
Sourcepub fn from_sources(
sources: Vec<Box<dyn PricingSource>>,
) -> Result<Self, PricingCatalogError>
pub fn from_sources( sources: Vec<Box<dyn PricingSource>>, ) -> Result<Self, PricingCatalogError>
Builds a resolver from imperative source implementations.
Sourcepub fn pricing_for_model(&self, model: &str) -> Option<ModelPricing>
pub fn pricing_for_model(&self, model: &str) -> Option<ModelPricing>
Finds model pricing for a canonical model ID or alias.
Sourcepub fn pricing_for(
&self,
provider: Option<&str>,
model: &str,
) -> Option<ModelPricing>
pub fn pricing_for( &self, provider: Option<&str>, model: &str, ) -> Option<ModelPricing>
Finds model pricing for a provider/model pair, with model-only fallback.
Sourcepub fn estimate_cost(&self, model: &str, usage: &Usage) -> Option<CostEstimate>
pub fn estimate_cost(&self, model: &str, usage: &Usage) -> Option<CostEstimate>
Estimates cost for a model/usage pair when model pricing is known.
Sourcepub fn estimate_cost_for_provider(
&self,
provider: Option<&str>,
model: &str,
usage: &Usage,
) -> Option<CostEstimate>
pub fn estimate_cost_for_provider( &self, provider: Option<&str>, model: &str, usage: &Usage, ) -> Option<CostEstimate>
Estimates cost for a provider/model pair when model pricing is known.
Trait Implementations§
Source§impl Clone for PricingResolver
impl Clone for PricingResolver
Source§fn clone(&self) -> PricingResolver
fn clone(&self) -> PricingResolver
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 PricingResolver
impl Debug for PricingResolver
Source§impl Default for PricingResolver
impl Default for PricingResolver
Source§fn default() -> PricingResolver
fn default() -> PricingResolver
Returns the “default value” for a type. Read more
Source§impl PartialEq for PricingResolver
impl PartialEq for PricingResolver
impl StructuralPartialEq for PricingResolver
Auto Trait Implementations§
impl Freeze for PricingResolver
impl RefUnwindSafe for PricingResolver
impl Send for PricingResolver
impl Sync for PricingResolver
impl Unpin for PricingResolver
impl UnsafeUnpin for PricingResolver
impl UnwindSafe for PricingResolver
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request