pub enum Pricing {
PerToken {
input_per_mtok: f64,
output_per_mtok: f64,
cache_write_per_mtok: Option<f64>,
cache_read_per_mtok: Option<f64>,
thinking_per_mtok: Option<f64>,
currency: String,
},
Credits {
credits_per_mtok_input: Option<f64>,
credits_per_mtok_output: Option<f64>,
credits_per_request: Option<f64>,
},
CharBased {
price_per_million_chars: f64,
output_multiplier: Option<f64>,
},
PerUnit {
metric: BillingDimension,
per_unit: f64,
currency: String,
},
Tiered {
dimension: BillingDimension,
tiers: Vec<PricingTier>,
currency: String,
},
}Expand description
Pricing formulas for cost calculation.
Variants§
PerToken
Per-token pricing (Anthropic, OpenAI, most providers).
Fields
Credits
Credit-based pricing (some resellers, internal platforms).
Fields
CharBased
Character-based pricing (some Chinese providers charge in CNY per million chars).
Fields
PerUnit
Flat per-unit pricing without tiers (video duration, image count, etc.).
Fields
§
metric: BillingDimensionWhat is being metered.
Tiered
Tiered/gradient pricing — rates change based on cumulative usage volume.
Fields
§
dimension: BillingDimensionWhat dimension is being metered.
§
tiers: Vec<PricingTier>Tiers ordered from lowest to highest range. The first tier whose
up_to covers the cumulative usage is selected.
Trait Implementations§
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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more