diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-26 08:50:20 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-26 08:50:20 +0300 |
| commit | e4a6723bb679b13401020bb4953cd7c4c9564e8c (patch) | |
| tree | 6404ac14586e6207056b83f3db8a1cd9657992d1 /internal/llmutils | |
| parent | 97e2dde7693618516a42019d7aa7cfda1f5a8811 (diff) | |
feat: optional API key for Ollama provider (Ollama Cloud)
Adds an optional HEXAI_OLLAMA_API_KEY (with OLLAMA_API_KEY fallback) so
the existing Ollama provider can target Ollama Cloud (ollama.ai) in
addition to a local server. When the key is empty the request is
unauthenticated, preserving local-server behavior byte-for-byte; when
set, an Authorization: Bearer header is attached for both Chat and
ChatStream. Documented cloud usage in config.toml.example.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'internal/llmutils')
| -rw-r--r-- | internal/llmutils/client.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/llmutils/client.go b/internal/llmutils/client.go index 3641556..ef24571 100644 --- a/internal/llmutils/client.go +++ b/internal/llmutils/client.go @@ -103,5 +103,11 @@ func NewClientFromApp(cfg appconfig.App) (llm.Client, error) { if strings.TrimSpace(anKey) == "" { anKey = os.Getenv("ANTHROPIC_API_KEY") } - return llm.NewFromConfig(llmCfg, oaKey, orKey, anKey) + // Ollama API key is optional: only needed for Ollama Cloud (ollama.ai). + // A local Ollama server keeps working when this is empty. + olKey := os.Getenv("HEXAI_OLLAMA_API_KEY") + if strings.TrimSpace(olKey) == "" { + olKey = os.Getenv("OLLAMA_API_KEY") + } + return llm.NewFromConfig(llmCfg, oaKey, orKey, anKey, olKey) } |
