Skip to main content

stakpak_shared/models/
model_pricing.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4pub struct ContextPricingTier {
5    pub label: String,
6    pub input_cost_per_million: f64,
7    pub output_cost_per_million: f64,
8    pub upper_bound: Option<u64>, // None means infinite/rest
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
12pub struct ModelContextInfo {
13    pub max_tokens: u64,
14    pub pricing_tiers: Vec<ContextPricingTier>,
15    pub approach_warning_threshold: f64, // e.g. 0.8 for 80%
16}
17
18impl Default for ModelContextInfo {
19    fn default() -> Self {
20        Self {
21            max_tokens: 128_000,
22            pricing_tiers: vec![],
23            approach_warning_threshold: 0.8,
24        }
25    }
26}
27
28pub trait ContextAware {
29    /// Returns context information for the model
30    fn context_info(&self) -> ModelContextInfo;
31
32    /// Returns the display name of the model
33    fn model_name(&self) -> String;
34}