Skip to main content

resolve_api_key

Function resolve_api_key 

Source
pub fn resolve_api_key(
    api_key: Option<&str>,
    provider: Provider,
) -> (Option<String>, ApiKeySource)
Expand description

Resolve API key from config or environment variable.

Resolution order:

  1. If api_key is Some and non-empty, use it (from config)
  2. Otherwise, check the provider’s environment variable
  3. If neither has a key, returns None (caller will use from_env())

Note: An empty string in config is treated as “not configured” and falls back to the environment variable. This allows users to override env vars in config while still supporting env-only setups.