Skip to content

Conversation

@aw338WoWmUI
Copy link

Summary

Enable configuring third-party Anthropic-compatible API endpoints (e.g., MiniMax, OpenRouter) through the base_url configuration option.

Changes

g3-providers/src/anthropic.rs

  • Add base_url field to AnthropicProvider struct
  • Refactor new() to delegate to new_with_name() to reduce code duplication
  • Add base_url parameter to new_with_name() with default to official Anthropic API URL
  • Update create_request_builder() to use self.base_url instead of hardcoded URL

g3-config/src/lib.rs

  • Add base_url: Option<String> field to AnthropicConfig

g3-core/src/provider_registration.rs

  • Pass base_url from config when registering Anthropic providers

g3-planner/src/llm.rs

  • Pass base_url when creating planner Anthropic provider

g3-providers/src/lib.rs

  • Add PartialEq derive to MessageRole (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

[providers.anthropic.minimax]
api_key = "your-api-key"
model = "MiniMax-M2.1"
base_url = "https://api.minimax.io/anthropic/v1/messages"

When base_url is not specified, it defaults to https://api.anthropic.com/v1/messages.

Compatibility

  • No breaking changes - base_url is optional with a sensible default
  • Existing configurations continue to work without modification

Note

There is an existing PR (#54) with similar functionality. This PR offers a more streamlined implementation:

  • new() delegates to new_with_name() instead of duplicating code
  • Minimal, focused changes without additional files (e.g., .gitignore updates)

If PR #54 is preferred, this PR can be closed.

Enable configuring third-party Anthropic-compatible API endpoints
(e.g., MiniMax, OpenRouter) through the base_url configuration option.

Changes:
- Add base_url field to AnthropicConfig and AnthropicProvider
- Refactor new() to delegate to new_with_name() to reduce duplication
- Update provider registration to pass base_url from config
- Add PartialEq derive to MessageRole for testing compatibility

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant