#[non_exhaustive]pub struct ContextTier {
pub above_prompt_tokens: u64,
pub input_per_million: f64,
pub output_per_million: f64,
pub cache_read_per_million: f64,
pub cache_write_per_million: f64,
}Expand description
Higher rates charged above a context threshold.
OpenAI prices gpt-5.5 at $5/$30 below 272K prompt tokens and $10/$45 above
it, and the GPT-6 models at 2x input and cache rates and 1.5x output above
the same line — published as columns on the same pricing row, which is
easy to miss if you go looking for a second row. A flat CostConfig under-bills those
requests by 2x on input, and this crate’s whole compaction subsystem exists
to run agents at high context, so the case is central rather than exotic.
The threshold is compared against the request’s prompt tokens —
input + cache_read + cache_write — not the total including output.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.above_prompt_tokens: u64Prompt tokens above which the tier rates apply.
input_per_million: f64§output_per_million: f64§cache_read_per_million: f64Cache-hit rate above the threshold. 0.0 bills at this tier’s
input_per_million, as for CostConfig::cache_read_per_million.
cache_write_per_million: f64Cache-write rate above the threshold. 0.0 bills at this tier’s
input_per_million, as for CostConfig::cache_write_per_million.
Implementations§
Source§impl ContextTier
impl ContextTier
Sourcepub fn new(
above_prompt_tokens: u64,
input_per_million: f64,
output_per_million: f64,
) -> Self
pub fn new( above_prompt_tokens: u64, input_per_million: f64, output_per_million: f64, ) -> Self
A tier’s threshold and the two rates every tier has.
Cache rates are added with with_cache_read
and with_cache_write, mirroring
CostConfig::new and for the same reason. A cache rate left unset
bills at this tier’s input rate (see CostConfig).
above_prompt_tokens is exclusive: a prompt exactly at the threshold
stays on the band below, matching how vendors publish >272K.
Sourcepub fn with_cache_read(self, per_million: f64) -> Self
pub fn with_cache_read(self, per_million: f64) -> Self
Rate for reading a cached prompt prefix above this threshold.
Sourcepub fn with_cache_write(self, per_million: f64) -> Self
pub fn with_cache_write(self, per_million: f64) -> Self
Rate for writing a prompt prefix into the cache above this threshold.
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
Whether this tier sets any rate. Mirrors CostConfig::is_configured.