{"record":{"id":"434924df322b479d","repo":"BerriAI/litellm","slug":"anthropic-api-base-anthropic-base-url-or-anthropic","errorCode":null,"errorMessage":"ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN is not set. Please set the environment variable, to query Anthropic's `/models` endpoint.","messagePattern":"ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN is not set\\. Please set the environment variable, to query Anthropic's `/models` endpoint\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/common_utils.py","lineNumber":786,"sourceCode":"        resolved_key: Final = AnthropicModelInfo.get_api_key(api_key)\n        if resolved_key is not None:\n            if is_anthropic_oauth_key(resolved_key):\n                return {\"authorization\": f\"Bearer {resolved_key}\"}\n            return AnthropicModelInfo._make_api_key_auth_header(resolved_key, api_base, use_bearer_for_custom_base)\n        auth_token: Final = AnthropicModelInfo.get_auth_token()\n        if auth_token is not None:\n            return {\"authorization\": f\"Bearer {auth_token}\"}\n        return None\n\n    @staticmethod\n    def get_base_model(model: str | None = None) -> str | None:\n        return model.replace(\"anthropic/\", \"\") if model else None\n\n    def get_models(self, api_key: str | None = None, api_base: str | None = None) -> list[str]:\n        api_base = AnthropicModelInfo.get_api_base(api_base)\n        auth_header: Final = AnthropicModelInfo.get_auth_header(api_key, api_base)\n        if api_base is None or auth_header is None:\n            raise ValueError(\n                \"ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN is not set. Please set the environment variable, to query Anthropic's `/models` endpoint.\"\n            )\n        headers: Final = {\"anthropic-version\": \"2023-06-01\"}\n        headers.update(auth_header)\n        response: Final = litellm.module_level_client.get(\n            url=f\"{api_base}/v1/models\",\n            headers=headers,\n        )\n\n        try:\n            response.raise_for_status()\n        except httpx.HTTPStatusError:\n            raise Exception(\n                f\"Failed to fetch models from Anthropic. Status code: {response.status_code}, Response: {response.text}\"\n            )\n\n        models: Final = response.json()[\"data\"]\n","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/anthropic/common_utils.py#L768-L804","documentation":"Error \"ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN is not set. Please set the environment variable, to query Anthropic's `/models` endpoint.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/common_utils.py:786 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.","Set ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL if using a custom endpoint."],"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-23T08:17:48.524Z"}