@@ -196,16 +196,29 @@ func setDefaults(debug bool) {
196196}
197197
198198// setProviderDefaults configures LLM provider defaults based on environment variables.
199- // the default model priority is:
200- // 1. Anthropic
201- // 2. OpenAI
202- // 3. Google Gemini
203- // 4. Groq
204- // 5. AWS Bedrock
205199func setProviderDefaults () {
206- // Anthropic configuration
200+ // Set all API keys we can find in the environment
207201 if apiKey := os .Getenv ("ANTHROPIC_API_KEY" ); apiKey != "" {
208202 viper .SetDefault ("providers.anthropic.apiKey" , apiKey )
203+ }
204+ if apiKey := os .Getenv ("OPENAI_API_KEY" ); apiKey != "" {
205+ viper .SetDefault ("providers.openai.apiKey" , apiKey )
206+ }
207+ if apiKey := os .Getenv ("GEMINI_API_KEY" ); apiKey != "" {
208+ viper .SetDefault ("providers.gemini.apiKey" , apiKey )
209+ }
210+ if apiKey := os .Getenv ("GROQ_API_KEY" ); apiKey != "" {
211+ viper .SetDefault ("providers.groq.apiKey" , apiKey )
212+ }
213+
214+ // Use this order to set the default models
215+ // 1. Anthropic
216+ // 2. OpenAI
217+ // 3. Google Gemini
218+ // 4. Groq
219+ // 5. AWS Bedrock
220+ // Anthropic configuration
221+ if apiKey := os .Getenv ("ANTHROPIC_API_KEY" ); apiKey != "" {
209222 viper .SetDefault ("agents.coder.model" , models .Claude37Sonnet )
210223 viper .SetDefault ("agents.task.model" , models .Claude37Sonnet )
211224 viper .SetDefault ("agents.title.model" , models .Claude37Sonnet )
@@ -214,7 +227,6 @@ func setProviderDefaults() {
214227
215228 // OpenAI configuration
216229 if apiKey := os .Getenv ("OPENAI_API_KEY" ); apiKey != "" {
217- viper .SetDefault ("providers.openai.apiKey" , apiKey )
218230 viper .SetDefault ("agents.coder.model" , models .GPT41 )
219231 viper .SetDefault ("agents.task.model" , models .GPT41Mini )
220232 viper .SetDefault ("agents.title.model" , models .GPT41Mini )
@@ -223,7 +235,6 @@ func setProviderDefaults() {
223235
224236 // Google Gemini configuration
225237 if apiKey := os .Getenv ("GEMINI_API_KEY" ); apiKey != "" {
226- viper .SetDefault ("providers.gemini.apiKey" , apiKey )
227238 viper .SetDefault ("agents.coder.model" , models .Gemini25 )
228239 viper .SetDefault ("agents.task.model" , models .Gemini25Flash )
229240 viper .SetDefault ("agents.title.model" , models .Gemini25Flash )
@@ -232,7 +243,6 @@ func setProviderDefaults() {
232243
233244 // Groq configuration
234245 if apiKey := os .Getenv ("GROQ_API_KEY" ); apiKey != "" {
235- viper .SetDefault ("providers.groq.apiKey" , apiKey )
236246 viper .SetDefault ("agents.coder.model" , models .QWENQwq )
237247 viper .SetDefault ("agents.task.model" , models .QWENQwq )
238248 viper .SetDefault ("agents.title.model" , models .QWENQwq )
0 commit comments