feat: Add support for custom Anthropic API endpoints #5
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
This PR introduces support for custom Anthropic API endpoints by adding a centralized client creation utility that respects the
ANTHROPIC_BASE_URLenvironment variable. This enables VC to work with Anthropic-compatible APIs, custom deployments, or alternative endpoints while maintaining backward compatibility.Key Changes
New Utility Function
NewAnthropicClient()ininternal/ai/utils.gothat:ANTHROPIC_BASE_URLenvironment variable for custom endpointsRefactored Client Instantiation
Replaced direct
anthropic.NewClient()calls with the new utility in:internal/ai/supervisor.go- AI supervision functionalityinternal/discovery/sdk/ai.go- AI discovery SDKinternal/executor/agent.go- Agent loop detectioninternal/executor/executor.go- Auto-commit message generationinternal/repl/conversation_state.go- REPL conversation handlinginternal/health/model_*_test.go- Test files for model cost/qualityBenefits
Usage
To use with a custom endpoint:
If
ANTHROPIC_BASE_URLis not set, the client will use the default Anthropic API endpoint.Testing
This enhancement makes VC more adaptable to different deployment scenarios and enables integration with custom AI infrastructure while maintaining simplicity for standard use cases.