[PR #5295] [CLOSED] feat: add custom base URL support for Anthropic provider #5396

Closed
opened 2026-06-05 15:21:13 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5295
Author: @satishkc7
Created: 3/28/2026
Status: Closed

Base: masterHead: feat/anthropic-custom-base-url


📝 Commits (1)

  • 945616b feat: add custom base URL support for Anthropic provider

📊 Changes

5 files changed (+35 additions, -0 deletions)

View changed files

📝 docker/.env.example (+1 -0)
📝 frontend/src/components/LLMSelection/AnthropicAiOptions/index.jsx (+21 -0)
📝 server/.env.example (+1 -0)
📝 server/utils/AiProviders/anthropic/index.js (+6 -0)
📝 server/utils/helpers/updateENV.js (+6 -0)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5295 **Author:** [@satishkc7](https://github.com/satishkc7) **Created:** 3/28/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feat/anthropic-custom-base-url` --- ### 📝 Commits (1) - [`945616b`](https://github.com/Mintplex-Labs/anything-llm/commit/945616b7869efd84cb7114a34dde4658676c7f15) feat: add custom base URL support for Anthropic provider ### 📊 Changes **5 files changed** (+35 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docker/.env.example` (+1 -0) 📝 `frontend/src/components/LLMSelection/AnthropicAiOptions/index.jsx` (+21 -0) 📝 `server/.env.example` (+1 -0) 📝 `server/utils/AiProviders/anthropic/index.js` (+6 -0) 📝 `server/utils/helpers/updateENV.js` (+6 -0) </details> ### 📄 Description 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 `AnthropicBaseURL` → `ANTHROPIC_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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 15:21:13 -04:00
yindo closed this issue 2026-06-05 15:21:13 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5396