litellm_rust/providers/
mod.rs1use crate::config::ProviderConfig;
2use crate::error::{LiteLLMError, Result};
3use std::env;
4
5pub mod anthropic;
6pub mod gemini;
7pub mod openai_compat;
8
9pub fn resolve_api_key(cfg: &ProviderConfig) -> Result<Option<String>> {
10 if cfg.no_auth {
11 return Ok(None);
12 }
13 if let Some(key) = cfg.api_key.clone() {
14 return Ok(Some(key));
15 }
16 if let Some(env_key) = cfg.api_key_env.as_deref() {
17 let key =
18 env::var(env_key).map_err(|_| LiteLLMError::MissingApiKey(env_key.to_string()))?;
19 return Ok(Some(key));
20 }
21 Err(LiteLLMError::MissingApiKey("<unset>".into()))
22}