fix(provider): allow remote Ollama without OPENAI_API_KEY (#369)#952
fix(provider): allow remote Ollama without OPENAI_API_KEY (#369)#9520xfandom wants to merge 1 commit intoGitlawb:mainfrom
Conversation
gnanam1990
left a comment
There was a problem hiding this comment.
Thanks for the PR! Scope is tight, fix addresses the root cause, and reusing the existing isLikelyOllamaEndpoint heuristic is the right call — keeps the rules in one place. Tests cover hostname, port, and the negative (non-Ollama remote still requires the key). CI green. LGTM.
|
Any update on this @kevincodex1 |
cbeb8e5 to
8cfe33b
Compare
|
Rebased onto current Same fix as before: 47 insertions, 4 deletions across providerConfig.ts + providerValidation.ts + providerValidation.test.ts. @gnanam1990 — re-approval ping if it still looks good. |
Remote Ollama servers (host outside the loopback / RFC1918 range, or on a domain like ollama.corp.example.com) hit the OPENAI provider validation gate that requires OPENAI_API_KEY whenever the base URL is not local. Ollama doesn't need an API key, so the user has to invent a phantom value to get past startup. Extend the bypass to recognise likely-Ollama base URLs in addition to local URLs: - port 11434 (Ollama default) on any host - 'ollama' substring in hostname or pathname isLikelyOllamaEndpoint already encoded these heuristics for tool-call gating in providerConfig.ts; export it and reuse so the rules stay in one place. Fixes Gitlawb#369
8cfe33b to
81e5825
Compare
|
Rebased onto current No logic changes since the prior approval. |
|
Any update on this @kevincodex1 @gnanam1990 |
Summary
ollama.corp.example.com) were being rejected at startup withOPENAI_API_KEY is required when CLAUDE_CODE_USE_OPENAI=1 and OPENAI_BASE_URL is not local.getProviderValidationErrorto bypass the API-key requirement when the base URL looks like Ollama (port11434on any host, orollamasubstring in hostname/pathname).isLikelyOllamaEndpointalready encoded these heuristics for tool-call gating inproviderConfig.ts; exported it and reused so the rules stay in one place.Impact
OPENAI_BASE_URLat a remote Ollama server (http://ollama.corp.example.com/v1,http://203.0.113.5:11434/v1, etc.) without settingOPENAI_API_KEY, matching the existing local-Ollama UX.isLikelyOllamaEndpointis now exported. No call-site changes elsewhere.Testing
bun run buildbun run smokebun test src/utils/providerValidation.test.ts— 10 pass, 4 newNotes
CLAUDE_CODE_USE_OPENAI=1with non-local Ollama-shaped base URLs (my-ollama-server.example.com:11434,203.0.113.5:11434,ollama.corp.example.com) — all clear validation; non-Ollama remote (api.openai.com) still requires the key.isLikelyOllamaEndpointalready used for tool-call gating; if the matching surface needs to be tighter (e.g. require both port AND host hint), the change would land inproviderConfig.tsand benefit both call sites.Fixes #369