MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_llm_provider

Function resolve_llm_provider

atomic-repository/src/ai/mod.rs:105–132  ·  view source on GitHub ↗

Resolve the best available LLM provider from environment.

()

Source from the content-addressed store, hash-verified

103
104/// Resolve the best available LLM provider from environment.
105pub fn resolve_llm_provider() -> Option<LlmProvider> {
106 if let Ok(key) = std::env::var("ANTHROPIC_API_KEY") {
107 if !key.is_empty() {
108 return Some(LlmProvider {
109 provider: AiProvider::Anthropic,
110 model: std::env::var("LLM_MODEL")
111 .unwrap_or_else(|_| "claude-haiku-4-5".to_string()),
112 api_key: key,
113 base_url: std::env::var("ANTHROPIC_BASE_URL")
114 .unwrap_or_else(|_| "https://api.anthropic.com/v1".to_string()),
115 });
116 }
117 }
118
119 if let Ok(key) = std::env::var("OPENAI_API_KEY") {
120 if !key.is_empty() {
121 return Some(LlmProvider {
122 provider: AiProvider::OpenAi,
123 model: std::env::var("LLM_MODEL").unwrap_or_else(|_| "gpt-4o-mini".to_string()),
124 api_key: key,
125 base_url: std::env::var("OPENAI_BASE_URL")
126 .unwrap_or_else(|_| "https://api.openai.com/v1".to_string()),
127 });
128 }
129 }
130
131 None
132}
133
134// ── Embedding API Calls ─────────────────────────────────────────
135

Callers 2

runMethod · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by 1