Skip to main content

Module proxy_setup

Module proxy_setup 

Source
Expand description

Install / uninstall LLM-client proxy environment wiring.

Submodules hold per-client setup (Claude, Codex, Grok, Pi, shell). This facade keeps the public API stable as crate::proxy_setup::*.

Functions§

anthropic_api_key_available
Returns true when an Anthropic API key is available for the proxy to forward upstream.
cleanup_stale_proxy_env
Removes stale proxy URLs from Claude Code / Codex settings when the proxy is not enabled. Returns the number of stale URLs cleaned up.
configured_proxy_live
Single source of truth for “is the proxy up” across doctor, status and gain: the proxy must be enabled in config AND the configured endpoint must answer as a lean-ctx proxy.
default_port
egress_routed_hosts
Hosts whose model traffic is routed through the local lean-ctx proxy right now (read-only). Requires the proxy to be enabled; a leftover local URL with the proxy off routes nothing and is reported as not routed.
grok_session_auth_available
True when ~/.grok/auth.json holds a session/OIDC access token (subscription).
has_stale_proxy_url
install_proxy_env
install_proxy_env_unchecked
Install proxy env without config guard (used by lean-ctx proxy enable which has already set the flag). force_endpoint: if true, overrides even non-local custom endpoints.
is_local_lean_ctx_url
True when url is the lean-ctx proxy itself: a loopback base URL on a port lean-ctx owns. Callers use this to decide what lean-ctx may overwrite or remove, so “any localhost URL” is not enough — another local gateway (Omniroute, LiteLLM, a corporate relay) belongs to the user (#1972).
lean_ctx_proxy_responding
True when the lean-ctx proxy itself answers GET /health on port. An open port alone proves nothing: a foreign process (or another user’s proxy) listening there must never count as “proxy up”.
preview_proxy_cleanup
proxy_timeout
Proxy reachability timeout. Priority: env var > config.toml > 200ms default.
uninstall_proxy_env
xai_api_key_available
True when an xAI API key is available for the API-key rail.