Skip to content

[Enhancement]: Support Anthropic API for Custom Endpoints in Agents or Allow Provider-Specific Agent Endpoints #10655

Description

@Byung-sun

What features would you like to see added?

Problem

I'm trying to restrict access to certain Claude models (Opus) to admin users only while allowing regular users to access only Sonnet models. My goal was to use a custom endpoint for agents that points to the Anthropic API, but this currently fails with a 404
error.

More details

Current Behavior

When configuring a custom endpoint pointing to Anthropic API in librechat.yaml:

custom:

  • name: 'Claude-Private'
    apiKey: '${ANTHROPIC_API_KEY}'
    baseURL: 'https://api.anthropic.com/v1'
    headers:
    anthropic-version: "2023-06-01"
    models:
    default:
    - 'claude-opus-4-1-20250805'
    - 'claude-opus-4-5-20251101'
    modelDisplayLabel: 'Claude-Private'
    dropParams: ['stop', 'frequency_penalty', 'presence_penalty', 'logit_bias', 'user']

agents:
allowedProviders: ["openAI", "anthropic", "google", "OpenRouter", "Claude-Private"]

Error: 404 Not Found - MODEL_NOT_FOUND

Root Cause Analysis:

Looking at the code in api/server/services/Endpoints/index.js, custom endpoints are automatically converted to use the OpenAI provider:

} else if (!getOptions) {
customEndpointConfig = getCustomEndpointConfig({ endpoint: provider, appConfig });
if (!customEndpointConfig) {
throw new Error(Provider ${provider} not supported);
}
getOptions = initCustom;
overrideProvider = Providers.OPENAI; // <-- Forces OpenAI provider
}

This causes LangChain to try calling the Anthropic API using the OpenAI client, which fails because Anthropic's API is not OpenAI-compatible.

Expected Behavior

One of the following solutions would resolve this issue:

Option 1: Allow custom endpoints to specify which provider/client to use
custom:

  • name: 'Claude-Private'
    provider: 'anthropic' # Specify which provider client to use
    apiKey: '${ANTHROPIC_API_KEY}'
    baseURL: 'https://api.anthropic.com/v1'

    ...

Option 2: Auto-detect provider based on baseURL

  • If baseURL contains anthropic.com, use Anthropic client
  • If baseURL contains openai.com, use OpenAI client
  • etc.

Option 3: Support agent-only endpoint configurations
endpoints:
anthropic:
models:
default: ['claude-sonnet-4-5-20250929'] # Available to all users
agentModels:
default: ['claude-opus-4-1-20250805'] # Only available in agents

Use Case

  • Regular users: Should only access Sonnet models through the main UI
  • Admin users with agent creation permission: Should be able to use Opus models in agents
  • Rationale: Cost control - Opus models are more expensive and should be restricted

Environment

  • LibreChat version: v0.8.0
  • Deployment: Docker (pre-built image ghcr.io/danny-avila/librechat-dev:latest)
  • Cannot modify source code (using pre-built images)

Workaround Attempted

Adding models to ANTHROPIC_MODELS environment variable works, but exposes them to all users, which defeats the purpose of role-based access control.

Proposed Solution Priority

  1. Option 2 (Auto-detect) - Least breaking change, works immediately
  2. Option 1 (Explicit provider) - Most flexible, clearest intent
  3. Option 3 (Agent-only models) - Most aligned with use case

Would appreciate any guidance or consideration for this feature!

Which components are impacted by your request?

No response

Pictures

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions