pub struct CostConfig {
pub default_model: Option<String>,
pub models: HashMap<String, String>,
pub prices: HashMap<String, PriceOverride>,
}Expand description
Model declaration for measured-vs-estimated cost reporting.
Proxy-routed clients (Claude Code, Codex, Pi, Gemini CLI, OpenCode) report their real model and billed tokens, so lean-ctx prices them measured with no configuration. MCP-only IDEs (Cursor, Copilot, Windsurf, VS Code, Zed) send their LLM traffic straight to the provider, bypassing lean-ctx — their real model is invisible. Declaring it here lets those estimated turns be priced with the correct model instead of a blended fallback.
Fields§
§default_model: Option<String>Fallback pricing model for any client without a per-client entry. Unset/empty → lean-ctx keeps its blended heuristic.
models: HashMap<String, String>Per-client pricing model, keyed by client id (cursor, copilot,
windsurf, claude, codex, …). Used for MCP-only IDEs whose real
model lean-ctx cannot observe. Example:
[cost.models] then cursor = "claude-opus-4.5".
prices: HashMap<String, PriceOverride>Operator price overrides (#1189), keyed by model name — for negotiated
enterprise rates (committed-use discounts, Azure PTU, zero-rated
internal models) that no public catalog can know. Merged into the
pricing table as exact entries, overriding embedded and live rows;
only a provider-measured bill beats them. Example:
[cost.prices."internal-llm"] then input_per_m = 0.10,
output_per_m = 0.40.
Implementations§
Source§impl CostConfig
impl CostConfig
Sourcepub fn model_for_client(&self, client: &str) -> Option<String>
pub fn model_for_client(&self, client: &str) -> Option<String>
Configured pricing model for a client id: the per-client entry first, then
the global default. None when neither is set (the caller then falls back
to the env override / heuristic). Blank entries are ignored.
Trait Implementations§
Source§impl Clone for CostConfig
impl Clone for CostConfig
Source§fn clone(&self) -> CostConfig
fn clone(&self) -> CostConfig
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 CostConfig
impl Debug for CostConfig
Source§impl Default for CostConfig
impl Default for CostConfig
Source§fn default() -> CostConfig
fn default() -> CostConfig
Source§impl<'de> Deserialize<'de> for CostConfigwhere
CostConfig: Default,
impl<'de> Deserialize<'de> for CostConfigwhere
CostConfig: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for CostConfig
impl Serialize for CostConfig
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,
Auto Trait Implementations§
impl Forget for CostConfig
impl Freeze for CostConfigwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<(String, String)>: Freeze,
PhantomData<(String, PriceOverride)>: Freeze,
impl Move for CostConfig
impl RefUnwindSafe for CostConfig
impl Send for CostConfig
impl Sync for CostConfig
impl Unpin for CostConfig
impl UnsafeUnpin for CostConfigwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
PhantomData<(String, PriceOverride)>: UnsafeUnpin,
impl UnwindSafe for CostConfigwhere
RawVecInner: UnwindSafe,
HashMap<String, String>: UnwindSafe,
HashMap<String, PriceOverride>: UnwindSafe,
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<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