feat(providers): support custom base_url for Anthropic provider #65
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
Enable configuring third-party Anthropic-compatible API endpoints (e.g., MiniMax, OpenRouter) through the
base_urlconfiguration option.Changes
g3-providers/src/anthropic.rs
base_urlfield toAnthropicProviderstructnew()to delegate tonew_with_name()to reduce code duplicationbase_urlparameter tonew_with_name()with default to official Anthropic API URLcreate_request_builder()to useself.base_urlinstead of hardcoded URLg3-config/src/lib.rs
base_url: Option<String>field toAnthropicConfigg3-core/src/provider_registration.rs
base_urlfrom config when registering Anthropic providersg3-planner/src/llm.rs
base_urlwhen creating planner Anthropic providerg3-providers/src/lib.rs
PartialEqderive toMessageRole(required for testing)Motivation
Some providers like MiniMax offer Anthropic-compatible API endpoints. This change allows users to configure these endpoints instead of being limited to the official Anthropic API.
Example Configuration
When
base_urlis not specified, it defaults tohttps://api.anthropic.com/v1/messages.Compatibility
base_urlis optional with a sensible defaultNote
There is an existing PR (#54) with similar functionality. This PR offers a more streamlined implementation:
new()delegates tonew_with_name()instead of duplicating codeIf PR #54 is preferred, this PR can be closed.