pub struct LlmConfig { /* private fields */ }Expand description
OpenRouter / Jev settings. Only constructed when a key is configured.
Implementations§
Source§impl LlmConfig
impl LlmConfig
Sourcepub fn new(api_key: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>) -> Self
Settings for api_key with every other field at its default.
Sourcepub fn from_env() -> Result<Option<Self>, ConfigError>
pub fn from_env() -> Result<Option<Self>, ConfigError>
Read the process environment. Ok(None) = no key configured.
Sourcepub fn from_lookup(
lookup: impl Fn(&str) -> Option<String>,
) -> Result<Option<Self>, ConfigError>
pub fn from_lookup( lookup: impl Fn(&str) -> Option<String>, ) -> Result<Option<Self>, ConfigError>
Self::from_env over an arbitrary variable lookup (tests).
The key comes from OPENROUTER_API_KEY, else from the file named by
CPM_OPENROUTER_KEY_FILE (contents trimmed). A world-readable (unix)
or empty key file is ConfigError::KeyFileIgnored (not logged here:
the caller logs it once).
A blank env key counts as absent. The endpoint is validated here:
https, or http to a loopback host, with no credentials.
Sourcepub fn with_jev_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_jev_endpoint(self, endpoint: impl Into<String>) -> Self
Replace the Jev endpoint (complete URL including the route). Not
validated: programmatic callers (tests) own it; the env path is
validated by Self::from_lookup.
Sourcepub fn with_jev_model(self, model: impl Into<String>) -> Self
pub fn with_jev_model(self, model: impl Into<String>) -> Self
Replace the Jev model id.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Replace the per-call timeout. The env var is bounded to 1..=300 s; programmatic callers (tests) may pick any duration.
Sourcepub fn jev_endpoint(&self) -> &str
pub fn jev_endpoint(&self) -> &str
The complete Jev endpoint URL.
Sourcepub fn jev_endpoint_host(&self) -> Option<String>
pub fn jev_endpoint_host(&self) -> Option<String>
Host of the Jev endpoint, from the parsed URL (see endpoint_host).