pub struct ProxyConfig {
pub anthropic_upstream: Option<String>,
pub openai_upstream: Option<String>,
pub gemini_upstream: Option<String>,
pub history_mode: Option<String>,
pub allow_insecure_http_upstream: Option<bool>,
pub meter_openai_usage: Option<bool>,
}Expand description
API proxy upstream overrides. None = use provider default.
Fields§
§anthropic_upstream: Option<String>§openai_upstream: Option<String>§gemini_upstream: Option<String>§history_mode: Option<String>History-pruning strategy for proxied chat requests.
“cache-aware” (default) | “rolling” | “off”. See HistoryMode.
allow_insecure_http_upstream: Option<bool>Allow a non-loopback plaintext http:// upstream (trusted local network
only). Opt-in; see ProxyConfig::allows_insecure_http_upstream. (#440)
meter_openai_usage: Option<bool>Inject stream_options.include_usage = true into streamed OpenAI Chat
Completions so the final chunk reports real token usage for the measured
spend meter. Default on; set false for a client that mishandles the
trailing usage chunk. Anthropic/Gemini/OpenAI-Responses report usage
without any request change, so this only affects Chat Completions.
Implementations§
Source§impl ProxyConfig
impl ProxyConfig
Sourcepub fn resolved_history_mode(&self) -> HistoryMode
pub fn resolved_history_mode(&self) -> HistoryMode
Resolved history mode: LEAN_CTX_PROXY_HISTORY_MODE env var wins,
then [proxy].history_mode in config.toml, then cache-aware.
Unknown values fall back to the default so a typo can never silently
re-enable the cache-hostile rolling mode.
Sourcepub fn meters_openai_usage(&self) -> bool
pub fn meters_openai_usage(&self) -> bool
Whether the proxy injects stream_options.include_usage into streamed
OpenAI Chat Completions to meter real spend. [proxy] meter_openai_usage
in config.toml, default true.
Sourcepub fn allows_insecure_http_upstream(&self) -> bool
pub fn allows_insecure_http_upstream(&self) -> bool
Whether a non-loopback plaintext http:// upstream is allowed. Opt-in
only — a deliberate downgrade for a trusted local-network service such as
http://host.docker.internal:2455 in front of codex-lb (#440).
LEAN_CTX_ALLOW_INSECURE_HTTP_UPSTREAM (any value) wins, then
[proxy] allow_insecure_http_upstream in config.toml, default false.
Sourcepub fn resolve_upstream(&self, provider: ProxyProvider) -> String
pub fn resolve_upstream(&self, provider: ProxyProvider) -> String
Effective upstream for a provider (env > config > default). An invalid configured/env value falls back to the provider default (logged) — the safe choice at startup.
Sourcepub fn resolve_all(&self) -> Upstreams
pub fn resolve_all(&self) -> Upstreams
Resolve all three upstreams at once (startup snapshot, env-aware).
Sourcepub fn resolve_all_disk(&self) -> Upstreams
pub fn resolve_all_disk(&self) -> Upstreams
Resolve all upstreams from config.toml only (ignoring LEAN_CTX_* env) —
the values a freshly (re)started managed proxy would serve. Used by
status/doctor to detect drift from a running proxy’s live upstream (#449).
Sourcepub fn refresh_upstreams(&self, last: &Upstreams) -> Upstreams
pub fn refresh_upstreams(&self, last: &Upstreams) -> Upstreams
Re-resolve upstreams for a running proxy (#449). For any provider whose currently configured/env value fails validation, the last good value is kept instead of rerouting live traffic to the provider default — so a typo in config.toml can never silently redirect in-flight requests.
Trait Implementations§
Source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
Source§fn clone(&self) -> ProxyConfig
fn clone(&self) -> ProxyConfig
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 ProxyConfig
impl Debug for ProxyConfig
Source§impl Default for ProxyConfig
impl Default for ProxyConfig
Source§fn default() -> ProxyConfig
fn default() -> ProxyConfig
Source§impl<'de> Deserialize<'de> for ProxyConfigwhere
ProxyConfig: Default,
impl<'de> Deserialize<'de> for ProxyConfigwhere
ProxyConfig: Default,
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>,
Auto Trait Implementations§
impl Freeze for ProxyConfig
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnsafeUnpin for ProxyConfig
impl UnwindSafe for ProxyConfig
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
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>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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