{"record":{"id":"03b4162d12efa890","repo":"BerriAI/litellm","slug":"api-base-is-required-to-forward-anthropic-v1-mess","errorCode":null,"errorMessage":"api_base is required to forward Anthropic /v1/messages to a native endpoint","messagePattern":"api_base is required to forward Anthropic /v1/messages to a native endpoint","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/openai_like/messages/transformation.py","lineNumber":66,"sourceCode":"            headers=normalized,\n            optional_params=optional_params,\n        )\n        return merged, api_base\n\n    def should_filter_anthropic_beta_headers(self) -> bool:\n        return False\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        if not api_base:\n            raise ValueError(\"api_base is required to forward Anthropic /v1/messages to a native endpoint\")\n        base = api_base.rstrip(\"/\")\n        if base.endswith(\"/v1/messages\"):\n            return base\n        base = base.removesuffix(\"/v1\")\n        return f\"{base}/v1/messages\"\n\n\nclass JSONProviderAnthropicMessagesConfig(OpenAILikeAnthropicMessagesConfig):\n    \"\"\"\n    Provider-level native Anthropic Messages passthrough for JSON-configured\n    OpenAI-compatible providers whose ``supported_endpoints`` in providers.json\n    includes ``\"/v1/messages\"``. Resolves the api key and api base from the\n    provider's configured env vars, then forwards the Anthropic payload\n    untranslated like ``OpenAILikeAnthropicMessagesConfig``.\n    \"\"\"\n\n    def __init__(self, provider: SimpleProviderConfig):\n        super().__init__()","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/openai_like/messages/transformation.py#L48-L84","documentation":"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.","triggerScenarios":"Thrown at litellm/llms/openai_like/messages/transformation.py:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass api_base pointing to the native Anthropic /v1/messages endpoint you want to forward to."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}