feat: add ANTHROPIC_BASE_URL setting for custom API endpoints - #210
Open
octo-patch wants to merge 1 commit into
Open
feat: add ANTHROPIC_BASE_URL setting for custom API endpoints#210octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
Add an optional ANTHROPIC_BASE_URL setting that configures the Claude Code SDK to use a proxy/enterprise endpoint or any Anthropic-compatible provider endpoint. ClaudeSDKManager exports the value to the ANTHROPIC_BASE_URL environment variable, preserving the existing SDK/session flow when the setting is left empty.
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.
Reason: provider-add — expose an Anthropic-compatible custom endpoint via the SDK extension point while preserving the existing SDK/session flow.
Changes
src/config/settings.py: add the optionalanthropic_base_urlfield plus theanthropic_base_url_strcomputed property (whitespace-trimmed), mirroring the existinganthropic_api_key/anthropic_api_key_strpair.src/claude/sdk_integration.py: inClaudeSDKManager.__init__, export the configured value to theANTHROPIC_BASE_URLenvironment variable (and clear it when unset) alongside the existingANTHROPIC_API_KEYhandling. The Claude Code SDK reads this env var, so the SDK/client construction and session flow are unchanged.Tests
tests/unit/test_claude/test_sdk_integration.py: addtest_sdk_manager_initialization_with_base_urlandtest_sdk_manager_initialization_without_base_url.tests/unit/test_config.py: addtest_anthropic_base_url_propertycovering unset, set, and whitespace-trimming cases.Verification
Ran with the project toolchain:
pytest tests/— 533 passed.black --check,isort --check-only, andflake8on the changedsrc/andtests/files — clean.mypy src/config/settings.py— no issues (pre-existing SDK typing notes insdk_integration.pyare unchanged and out of scope).Documentation
.env.example,README.md,docs/configuration.md, andCHANGELOG.mddocument the newANTHROPIC_BASE_URLoption.