pub struct ClientConfig {
pub api_key: SecretString,
pub base_url: Option<String>,
pub timeout: Duration,
pub max_retries: u32,
pub credential_provider: Option<Arc<dyn CredentialProvider>>,
pub load_env: bool,
/* private fields */
}Expand description
Configuration for an LLM client.
api_key is stored as a SecretString so it is zeroed on drop and never
printed accidentally. Access it via secrecy::ExposeSecret.
Fields§
§api_key: SecretStringAPI key for authentication (stored as a secret).
base_url: Option<String>Override base URL. When set, all requests go here regardless of model name, and provider auto-detection is skipped.
timeout: DurationRequest timeout.
max_retries: u32Maximum number of retries on 429 / 5xx responses.
credential_provider: Option<Arc<dyn CredentialProvider>>Optional dynamic credential provider for token-based auth (Azure AD, Vertex OAuth2) or refreshable credentials (AWS STS).
When set, the client calls resolve() before each request to obtain
a fresh credential. When None, the static api_key is used.
load_env: boolAutomatically load the API key from the provider’s environment variable when no explicit key is provided.
When true (the default) and api_key is empty, [DefaultClient::new]
reads the provider’s designated environment variable (e.g.
OPENAI_API_KEY for OpenAI). Set to false to suppress this behaviour
and require the caller to supply the key explicitly.
Has no effect on WASM targets, where std::env::var is unavailable.
Implementations§
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more