From b6cc57590a1ce5911ae0bdac8281ede52815ed4c Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 15 Dec 2025 11:18:05 +0000 Subject: [PATCH] fix(ai): use configured provider's default model when no model set When a user configures only Ollama (or any single provider) via the multi-provider UI without explicitly selecting a model, GetModel() now returns that provider's default model instead of falling back to the legacy Provider field which defaults to "anthropic". This fixes "API key is required for anthropic" errors when enabling AI with only Ollama configured. Related to #847 --- internal/config/ai.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/config/ai.go b/internal/config/ai.go index 3698973..7f5bd70 100644 --- a/internal/config/ai.go +++ b/internal/config/ai.go @@ -286,6 +286,24 @@ func (c *AIConfig) GetModel() string { if c.Model != "" { return c.Model } + + // If only one provider is configured, use its default model + // This handles the case where user configures Ollama but doesn't explicitly select a model + configured := c.GetConfiguredProviders() + if len(configured) == 1 { + switch configured[0] { + case AIProviderAnthropic: + return DefaultAIModelAnthropic + case AIProviderOpenAI: + return DefaultAIModelOpenAI + case AIProviderOllama: + return DefaultAIModelOllama + case AIProviderDeepSeek: + return DefaultAIModelDeepSeek + } + } + + // Fall back to legacy Provider field for backwards compatibility switch c.Provider { case AIProviderAnthropic: return DefaultAIModelAnthropic