{"record":{"id":"cc1493c8f45f8c6f","repo":"BerriAI/litellm","slug":"missing-anthropic-api-key-a-call-is-being-made-t-cc1493","errorCode":null,"errorMessage":"Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params","messagePattern":"Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/completion/transformation.py","lineNumber":90,"sourceCode":"    ) -> None:\n        locals_: Final = locals().copy()\n        for key, value in locals_.items():\n            if key != \"self\" and value is not None:\n                setattr(self.__class__, key, value)\n\n    # makes headers for API call\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        if api_key is None:\n            raise ValueError(\n                \"Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params\"\n            )\n        _headers: Final = {\n            \"accept\": \"application/json\",\n            \"anthropic-version\": \"2023-06-01\",\n            \"content-type\": \"application/json\",\n            \"x-api-key\": api_key,\n        }\n        headers.update(_headers)\n        return headers\n\n    def transform_request(\n        self,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        headers: dict,","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/completion/transformation.py#L72-L108","documentation":"Error \"Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/completion/transformation.py:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set ANTHROPIC_API_KEY in the environment or pass api_key."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}