-
Notifications
You must be signed in to change notification settings - Fork 392
feat: support ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN for custom endpoints #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN for custom endpoints #339
Conversation
…endpoints - apps/server/src/providers/claude-provider.ts Add ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to the environment variable allowlist, enabling use of LLM gateways (LiteLLM, Helicone) and Anthropic- compatible providers (GLM 4.7, Minimax M2.1, etc.). Closes AutoMaker-Org#338
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughExtended the Claude provider's environment allowlist to include Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
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 |
Summary of ChangesHello @ramarivera, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces greater flexibility for integrating with Anthropic's API by allowing users to specify custom base URLs and authentication tokens via new environment variables. This change is crucial for supporting LLM gateways and other Anthropic-compatible services, thereby expanding the interoperability of AutoMaker with diverse AI infrastructure setups. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to enable using custom Anthropic-compatible endpoints. The change correctly adds these environment variables to the allowlist in claude-provider.ts. However, this change is incomplete as it doesn't update other parts of the application that handle authentication, which will cause issues for users relying on ANTHROPIC_AUTH_TOKEN. I have added a comment highlighting the necessary changes to fully support this new authentication method. Additionally, it would be helpful to add ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN to the .env.example file to document these new options for users.
| const ALLOWED_ENV_VARS = [ | ||
| 'ANTHROPIC_API_KEY', | ||
| 'ANTHROPIC_BASE_URL', | ||
| 'ANTHROPIC_AUTH_TOKEN', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While adding ANTHROPIC_AUTH_TOKEN to the allowlist is necessary, its introduction is incomplete and will cause issues with authentication checks, as several places in the codebase only check for ANTHROPIC_API_KEY.
For example, the detectInstallation method in this very file will incorrectly report that no API key is configured if only ANTHROPIC_AUTH_TOKEN is provided.
To fix this and ensure consistent behavior, all checks for authentication credentials should be updated to consider both ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN.
Here are some of the locations that need to be updated:
detectInstallation()inapps/server/src/providers/claude-provider.ts- The handler in
apps/server/src/routes/setup/routes/api-keys.ts - The handler in
apps/server/src/routes/setup/routes/verify-claude-auth.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramarivera , i tried to apply this change and run dev:electron - UI shows auth errors. Did you try a non-docker run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh sorry I somehow missed this message!, will take a look as soon as I can
…hrough - apps/server/tests/unit/providers/claude-provider.test.ts Verify custom endpoint environment variables are passed to the SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/server/tests/unit/providers/claude-provider.test.ts (1)
291-377: Well-structured test suite for custom endpoint support.The tests properly verify that
ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENare passed through to the SDK when set, covering individual and combined scenarios. The cleanup inafterEachensures test isolation.Optional: Consider testing the negative case
You might add a test verifying that when these env vars are NOT set, the
options.enveither doesn't contain them or the provider handles their absence gracefully. This would document the default behavior explicitly.it('should not include custom endpoint vars when not set', async () => { // Ensure vars are not set (already done in beforeEach, but explicit here) delete process.env.ANTHROPIC_BASE_URL; delete process.env.ANTHROPIC_AUTH_TOKEN; vi.mocked(sdk.query).mockReturnValue( (async function* () { yield { type: 'text', text: 'test' }; })() ); const generator = provider.executeQuery({ prompt: 'Test', cwd: '/test', }); await collectAsyncGenerator(generator); const callArgs = vi.mocked(sdk.query).mock.calls[0][0]; // Verify ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are not in env // or that env is undefined/doesn't contain these keys expect(callArgs.options.env?.ANTHROPIC_BASE_URL).toBeUndefined(); expect(callArgs.options.env?.ANTHROPIC_AUTH_TOKEN).toBeUndefined(); });This is optional as the existing tests likely cover the default behavior adequately.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/server/tests/unit/providers/claude-provider.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Always import from shared packages (@automaker/*), never from old relative paths
Files:
apps/server/tests/unit/providers/claude-provider.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use
resolveModelString()from @automaker/model-resolver to convert model aliases (haiku, sonnet, opus) to full model names
Files:
apps/server/tests/unit/providers/claude-provider.test.ts
🧬 Code graph analysis (1)
apps/server/tests/unit/providers/claude-provider.test.ts (1)
apps/server/tests/utils/helpers.ts (1)
collectAsyncGenerator(8-14)
🔇 Additional comments (2)
apps/server/tests/unit/providers/claude-provider.test.ts (2)
15-16: LGTM! Proper test isolation.The cleanup of environment variables in
beforeEachensures tests start with a clean state and don't interfere with each other.
292-295: Good practice: localized cleanup.The
afterEachcleanup within this describe block provides an additional layer of test isolation. While the suite-levelbeforeEach(lines 15-16) also cleans these vars, having localized cleanup is a defensive practice that ensures these tests clean up after themselves.

Summary
ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENto the environment variable allowlistEnables use of LLM gateways and Anthropic-compatible providers with AutoMaker.
Usage
Closes #338
Summary by CodeRabbit
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.