BerriAI/litellm · error · ValueError

api_base is required to forward Anthropic /v1/messages to a

Error message

api_base is required to forward Anthropic /v1/messages to a native endpoint

What it means

Configuration guard in the OpenAI-like Anthropic-compat transformation's get_complete_url: api_base is falsy. Because these requests forward /v1/messages to a self-hosted/native endpoint, an explicit base URL is mandatory and the call is rejected without one.

Source

Thrown at litellm/llms/openai_like/messages/transformation.py:66

            headers=normalized,
            optional_params=optional_params,
        )
        return merged, api_base

    def should_filter_anthropic_beta_headers(self) -> bool:
        return False

    def get_complete_url(
        self,
        api_base: str | None,
        api_key: str | None,
        model: str,
        optional_params: dict,
        litellm_params: dict,
        stream: bool | None = None,
    ) -> str:
        if not api_base:
            raise ValueError("api_base is required to forward Anthropic /v1/messages to a native endpoint")
        base = api_base.rstrip("/")
        if base.endswith("/v1/messages"):
            return base
        base = base.removesuffix("/v1")
        return f"{base}/v1/messages"


class JSONProviderAnthropicMessagesConfig(OpenAILikeAnthropicMessagesConfig):
    """
    Provider-level native Anthropic Messages passthrough for JSON-configured
    OpenAI-compatible providers whose ``supported_endpoints`` in providers.json
    includes ``"/v1/messages"``. Resolves the api key and api base from the
    provider's configured env vars, then forwards the Anthropic payload
    untranslated like ``OpenAILikeAnthropicMessagesConfig``.
    """

    def __init__(self, provider: SimpleProviderConfig):
        super().__init__()

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass api_base pointing to the native Anthropic /v1/messages endpoint you want to forward to.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/openai_like/messages/transformation.py:66 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/03b4162d12efa890. Report an issue: GitHub.