pub struct Pricing {
pub input: u64,
pub output: u64,
pub cache_read: u64,
pub cache_write: u64,
}Expand description
What a model’s tokens cost, as the deployment states it.
Every rate is in minor units per million tokens — integers, so a price cannot fail to bind by a rounding error. There is no built-in price table: rates change, differ per model and per contract, and a number this crate guessed would be a ceiling that binds at the wrong place without saying so, so a deployment that declares a money ceiling states what its models cost.
All four rates are required. Cache writes are billed at a premium and cache
reads at a fraction of the input rate, and defaulting either to the input
rate would be a guess in one direction or the other; a provider with no
cache-write charge states 0.
Fields§
§input: u64Ordinary input tokens — neither written to nor read from a cache.
output: u64Generated tokens, reasoning included.
cache_read: u64Input tokens served from a cache.
cache_write: u64Input tokens written into a cache.
Implementations§
Source§impl Pricing
impl Pricing
Sourcepub fn price(&self, usage: &Usage) -> u64
pub fn price(&self, usage: &Usage) -> u64
What usage costs, in minor units, rounded up.
Up, because this figure feeds a ceiling: a call priced at a fraction of a cent is not free, and a thousand of them rounded down would pass a money limit they exceeded. Saturating, because the counts are whatever a provider’s response said they were.
Trait Implementations§
impl Copy for Pricing
Source§impl<'de> Deserialize<'de> for Pricing
impl<'de> Deserialize<'de> for Pricing
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>,
impl Eq for Pricing
Source§impl JsonSchema for Pricing
impl JsonSchema for Pricing
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Pricing
Auto Trait Implementations§
impl Freeze for Pricing
impl RefUnwindSafe for Pricing
impl Send for Pricing
impl Sync for Pricing
impl Unpin for Pricing
impl UnsafeUnpin for Pricing
impl UnwindSafe for Pricing
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
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>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 more