pub struct CostEstimate {
pub total: Option<f64>,
pub currency: String,
pub input: Option<f64>,
pub output: Option<f64>,
pub cache_read: Option<f64>,
pub cache_write: Option<f64>,
pub source: CostSource,
pub pricing_provider: Option<String>,
pub pricing_model: Option<String>,
pub pricing_as_of: Option<String>,
pub pricing_source: Option<String>,
}Expand description
Normalized LLM response cost.
Provider-reported cost is preserved as-is. Model-pricing estimates include source and as-of metadata so downstream systems can audit stale pricing tables without losing a usable estimate.
Fields§
§total: Option<f64>Total cost in currency.
currency: StringISO 4217 currency code for the cost fields.
input: Option<f64>Uncached prompt/input token cost in currency.
output: Option<f64>Completion/output token cost in currency.
cache_read: Option<f64>Prompt cache read cost in currency.
cache_write: Option<f64>Prompt cache write cost in currency.
source: CostSourceOrigin of this cost value.
pricing_provider: Option<String>Provider associated with the cost or pricing estimate, if known.
pricing_model: Option<String>Model ID associated with the cost or pricing estimate, if known.
pricing_as_of: Option<String>Date the pricing value was last verified, if known.
pricing_source: Option<String>Source URL or label for the pricing value, if known.
Implementations§
Source§impl CostEstimate
impl CostEstimate
Sourcepub fn total_or_component_sum(&self) -> Option<f64>
pub fn total_or_component_sum(&self) -> Option<f64>
Returns the explicit total, or the sum of component costs when no total was supplied.
Sourcepub fn total_for_currency(&self, currency: &str) -> Option<f64>
pub fn total_for_currency(&self, currency: &str) -> Option<f64>
Returns the total only when it is denominated in the requested currency.
Sourcepub fn total_or_component_sum_for_currency(&self, currency: &str) -> Option<f64>
pub fn total_or_component_sum_for_currency(&self, currency: &str) -> Option<f64>
Returns the explicit or component-derived total in the requested currency.
Trait Implementations§
Source§impl Clone for CostEstimate
impl Clone for CostEstimate
Source§fn clone(&self) -> CostEstimate
fn clone(&self) -> CostEstimate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CostEstimate
impl Debug for CostEstimate
Source§impl<'de> Deserialize<'de> for CostEstimate
impl<'de> Deserialize<'de> for CostEstimate
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostEstimate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostEstimate, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CostEstimate
impl PartialEq for CostEstimate
Source§impl Serialize for CostEstimate
impl Serialize for CostEstimate
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for CostEstimate
Auto Trait Implementations§
impl Freeze for CostEstimate
impl RefUnwindSafe for CostEstimate
impl Send for CostEstimate
impl Sync for CostEstimate
impl Unpin for CostEstimate
impl UnsafeUnpin for CostEstimate
impl UnwindSafe for CostEstimate
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
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>,
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> ⓘ
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> ⓘ
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>
T in a tonic::Request