Skip to content

feat: add custom base URL support for Anthropic provider#5295

Closed
satishkc7 wants to merge 1 commit intoMintplex-Labs:masterfrom
satishkc7:feat/anthropic-custom-base-url
Closed

feat: add custom base URL support for Anthropic provider#5295
satishkc7 wants to merge 1 commit intoMintplex-Labs:masterfrom
satishkc7:feat/anthropic-custom-base-url

Conversation

@satishkc7
Copy link
Copy Markdown

Closes #5234

What

Adds an optional ANTHROPIC_BASE_URL setting that lets users route the Anthropic provider to any Anthropic-compatible backend instead of the default api.anthropic.com.

Why

Self-hosted inference servers (oMLX, Azure AI Foundry, local proxies) expose Anthropic-compatible /v1/messages APIs but have no way to be used with the Anthropic provider today. Users are forced to use Generic OpenAI as a workaround, losing Anthropic-specific UX (model picker, prompt caching, etc.).

Changes

File Change
server/utils/AiProviders/anthropic/index.js Pass baseURL to AnthropicAI constructor and fetchModelMaxTokens when ANTHROPIC_BASE_URL is set
server/utils/helpers/updateENV.js Register AnthropicBaseURLANTHROPIC_BASE_URL with isValidURL check; relax sk-ant- key format check when a custom base URL is present
frontend/src/components/LLMSelection/AnthropicAiOptions/index.jsx Add "Custom Base URL" input in the existing advanced settings panel
server/.env.example / docker/.env.example Document ANTHROPIC_BASE_URL

Review notes

  • No changes to existing behavior when ANTHROPIC_BASE_URL is unset — the SDK uses its default endpoint
  • The API key format check (sk-ant-) is bypassed only when a custom base URL is configured, since third-party backends accept arbitrary key strings
  • The UI field is placed alongside the existing Prompt Caching control in the advanced settings section to keep the primary settings clean

Allows users to point the Anthropic provider at self-hosted or
Anthropic-compatible backends (e.g. oMLX, Azure AI Foundry) by
setting a custom base URL instead of the default api.anthropic.com.

Changes:
- Pass ANTHROPIC_BASE_URL to the AnthropicAI SDK constructor in both
  the main client and fetchModelMaxTokens static helper
- Register AnthropicBaseURL in updateENV.js with isValidURL validation
- Relax the sk-ant- API key format check when a custom base URL is set,
  since self-hosted backends may use arbitrary key formats
- Add Base URL input field in the advanced settings panel of the
  Anthropic options UI
- Document ANTHROPIC_BASE_URL in server and docker .env.example files

Closes Mintplex-Labs#5234
@timothycarambat
Copy link
Copy Markdown
Member

The Anthropic provider is only for Anthropic intentionally. If we want to support this it has to be through a new Generic like OpenAI - or move Generic OpenAi to just Generic and then have the endpoint be anthropic, openai, or even ollama compatible

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.

[FEAT]: Add custom base URL for Anthropic provider and optional model discovery for Generic OpenAI

2 participants