fix(llm): wire base_url into AnthropicLLM and ZaiLLM clients - #968
Merged
wayyoungboy merged 2 commits intoJun 5, 2026
Merged
Conversation
AnthropicConfig already declares `anthropic_base_url` (env: ANTHROPIC_BASE_URL) and ZaiConfig already declares `zai_base_url` (env: ZAI_BASE_URL), but neither value was forwarded to the SDK client constructor. For Anthropic: pass base_url to anthropic.Anthropic(). For ZAI: Zhipu AI exposes an OpenAI-compatible endpoint, so replace the ZhipuAiClient dependency with openai.OpenAI and pass base_url directly — no behavioural change since the response format is identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AnthropicConfigalready declaresanthropic_base_url(env:ANTHROPIC_LLM_BASE_URL) butAnthropicLLM.__init__never forwarded it to theanthropic.Anthropic()constructor — the fieldwas silently ignored.
ANTHROPIC_BASE_URLso users whose Claude Code sets that variableautomatically get the correct endpoint without extra
.envconfig.ZaiConfigalready declareszai_base_url(env:ZAI_BASE_URL, defaulthttps://open.bigmodel.cn/api/paas/v4/) butZaiLLM.__init__never forwarded it either.ZhipuAiClient(from thezaiSDK) withopenai.OpenAIsince Zhipu AI exposesan OpenAI-compatible endpoint —
base_urlis then passed directly, and a separate SDKdependency is removed with no behaviour change.
tests/unit/test_openai.py.Motivation
Users pointing
AnthropicLLMorZaiLLMat a private proxy or a regional mirror had noworking way to redirect requests even though the config fields existed:
anthropic_base_urlANTHROPIC_LLM_BASE_URLapi.anthropic.comANTHROPIC_BASE_URLzai_base_urlZAI_BASE_URLChanges
src/powermem/integrations/llm/anthropic.pyanthropic_base_urlfrom config andANTHROPIC_BASE_URLfrom env; passbase_urltoanthropic.Anthropic()src/powermem/integrations/llm/zai.pyZhipuAiClientwithopenai.OpenAI; readzai_base_urlfrom config and pass asbase_urltests/unit/test_anthropic.pyANTHROPIC_LLM_BASE_URL, andANTHROPIC_BASE_URLtests/unit/test_zai.pyZAI_BASE_URL,generate_response, callbackTest plan
pytest tests/unit/test_anthropic.py tests/unit/test_zai.py— 6 passedzai_base_urlexplicitly set — response returned correctlyzai_base_url— response returned correctlyAnthropicLLMwithanthropic_base_urlconfig field —client.base_urlmatchesAnthropicLLMwithANTHROPIC_BASE_URLenv var —client.base_urlmatches