Soporte base_url custom en Claude adapter (MiniMax Anthropic-compatible)

MiniMax tiene endpoint compatible con Anthropic API en
https://api.minimax.io/anthropic/v1. Nueva variable
AGENTIC_ANTHROPIC_BASE_URL para usarlo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jordan Diaz
2026-04-04 10:42:40 +00:00
parent 00c41fedb2
commit 72da3b7659
2 changed files with 9 additions and 4 deletions

View File

@@ -17,10 +17,14 @@ logger = logging.getLogger(__name__)
class ClaudeAdapter(ModelAdapter): class ClaudeAdapter(ModelAdapter):
"""Adapter for the Anthropic Claude API.""" """Adapter for the Anthropic Claude API."""
def __init__(self, api_key: str | None = None) -> None: def __init__(self, api_key: str | None = None, base_url: str | None = None) -> None:
self._client = anthropic.AsyncAnthropic( kwargs: dict[str, Any] = {
api_key=api_key or settings.anthropic_api_key, "api_key": api_key or settings.anthropic_api_key,
) }
url = base_url or settings.anthropic_base_url
if url:
kwargs["base_url"] = url
self._client = anthropic.AsyncAnthropic(**kwargs)
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# Streaming # Streaming

View File

@@ -29,6 +29,7 @@ class Settings(BaseSettings):
# --- Model providers --- # --- Model providers ---
anthropic_api_key: str = "" anthropic_api_key: str = ""
anthropic_base_url: str = "" # Custom base URL (for MiniMax Anthropic-compatible, etc.)
openai_api_key: str = "" openai_api_key: str = ""
openai_base_url: str = "" # Custom base URL (for MiniMax, DeepInfra, etc.) openai_base_url: str = "" # Custom base URL (for MiniMax, DeepInfra, etc.)
default_model_provider: str = "claude" default_model_provider: str = "claude"