fix(llm): pass base_url to default provider clients from LLMSettings#643
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR adds optional base URL configuration fields ( ChangesProvider Base URL Configuration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/llm/registry.py`:
- Around line 111-120: The startup will raise an AttributeError because the code
instantiates genai.client.Client instead of the public genai.Client; update the
instantiation used when settings.LLM.GEMINI_API_KEY is present so
CLIENTS["gemini"] is created with genai.Client(...), preserving the existing
http_options and api_key args (refer to settings.LLM.GEMINI_API_KEY,
settings.LLM.GEMINI_BASE_URL, http_options, and CLIENTS["gemini"] in the block)
to match the SDK and other usages in this file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2d4b1380-a38a-40d3-ad14-58da59b8a470
📒 Files selected for processing (2)
src/config.pysrc/llm/registry.py
Sync fork with upstream through 9f26fdd (v3.0.2 → v3.0.9). No conflicts; local CLAUDE.md (GitNexus block) auto-merged. Notable: base_url threading to LLM clients (plastic-labs#643), configurable embeddings (plastic-labs#678), deriver custom instructions (plastic-labs#609). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Fixes #641 — when self-hosting Honcho with an OpenAI-compatible provider (OpenRouter, vLLM, Together, Anyscale, etc.), every LLM call fails with 401 because the default
AsyncOpenAIclient always hitshttps://api.openai.com/v1instead of the configured proxy.Root Cause
LLMSettingshasOPENAI_API_KEYbut noOPENAI_BASE_URLfield (same for Anthropic and Gemini). The default client construction inregistry.pynever passesbase_url:The per-service override path (
MODEL_CONFIG__OVERRIDES__BASE_URL) works correctly, but operators who setLLM_OPENAI_BASE_URLin.envexpect the default client to use it too.Changes
src/config.py: AddOPENAI_BASE_URL,ANTHROPIC_BASE_URL,GEMINI_BASE_URLtoLLMSettings(env vars:LLM_OPENAI_BASE_URL,LLM_ANTHROPIC_BASE_URL,LLM_GEMINI_BASE_URL).src/llm/registry.py: Passbase_urlfrom settings to all three default client constructors (CLIENTSdict entries andget_*_client()helpers).Backward Compatibility
All three
*_BASE_URLfields default toNone, so existing deployments that don't set them are unaffected. TheAsyncOpenAI(api_key=..., base_url=None)behavior is identical toAsyncOpenAI(api_key=...)— the SDK uses its default endpoint.Test Plan
LLM_OPENAI_BASE_URL=https://openrouter.ai/api/v1andLLM_OPENAI_API_KEY=sk-or-v1-...in.envopenrouter.aiinstead ofapi.openai.comSummary by CodeRabbit