feat: support custom baseURL via opencode.json and ANTHROPIC_BASE_URL…#229
Open
anxjok wants to merge 1 commit into
Open
feat: support custom baseURL via opencode.json and ANTHROPIC_BASE_URL…#229anxjok wants to merge 1 commit into
anxjok wants to merge 1 commit into
Conversation
… env var - Add support for configuring custom base URL in opencode.json via provider.anthropic.options.baseURL - Add fallback to ANTHROPIC_BASE_URL environment variable - Maintain backward compatibility with default Anthropic API endpoint - Priority: config > env var > default This enables routing Anthropic API requests through proxies, API gateways, and custom endpoints while maintaining OAuth authentication through Claude Code credentials. Features: - Custom headers from provider.anthropic.options.headers are automatically forwarded - Useful for authentication headers (e.g., X-Gateway-Key) - Verified to work with proxies and load balancers Closes: Support for proxy/gateway setups requested by users
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
Add support for configuring a custom Anthropic API base URL via
opencode.jsonor theANTHROPIC_BASE_URLenvironment variable. This enables routing Anthropic API requests through proxies, API gateways, and custom endpoints while maintaining OAuth authentication through Claude Code credentials.Key features:
opencode.jsonviaprovider.anthropic.options.baseURLANTHROPIC_BASE_URLenvironment variableprovider.anthropic.options.headersare automatically forwarded (useful for authentication headers likeX-Gateway-Key)Related issue
Closes #160 (FR: Anthropic API mode for e.g. CLIProxyAPI)
Testing
X-Gateway-Key) forwarded correctlyTest coverage includes:
provider.anthropic.options.baseURLfrom opencode.json when providedANTHROPIC_BASE_URLenvironment variable when set (no config)/v1path segment (correct URL merging)Checklist
feat:)make allpasses locally (runs lint, build, and test)src/index.test.ts)ANTHROPIC_BASE_URLenv var documentation)