fix(ai): allow Ollama Cloud API key in AI settings (#4262)

The Ollama detection matched any URL containing "ollama", which hides
the API Key field for Ollama Cloud (ollama.com) and drops the key from
the createOllama() client, so cloud requests go out unauthenticated.

Narrow the rule to localhost-only Ollama and forward the API key as a
Bearer header when provided.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
VincentEmmanuel
2026-07-06 07:03:08 +08:00
committed by GitHub
parent f8a3561f1e
commit ca2708a58a
2 changed files with 9 additions and 4 deletions

View File

@@ -74,8 +74,10 @@ export function selectAIProvider(config: { apiUrl: string; apiKey: string }) {
});
case "ollama":
return createOllama({
// optional settings, e.g.
baseURL: config.apiUrl,
headers: config.apiKey
? { Authorization: `Bearer ${config.apiKey}` }
: undefined,
});
case "deepinfra":
return createDeepInfra({