{"record":{"id":"9ead571312188c44","repo":"BerriAI/litellm","slug":"anthropic-api-key-is-required-set-anthropic-api-k","errorCode":null,"errorMessage":"Anthropic API key is required. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN environment variable or pass api_key parameter.","messagePattern":"Anthropic API key is required\\. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN environment variable or pass api_key parameter\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/files/transformation.py","lineNumber":101,"sourceCode":"            message=error_message,\n            headers=(cast(httpx.Headers, headers) if isinstance(headers, dict) else headers),\n        )\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list,\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_base is None and isinstance(litellm_params, dict):\n            api_base = litellm_params.get(\"api_base\")\n        auth_header: Final = AnthropicModelInfo.get_auth_header(api_key, api_base)\n        if auth_header is None:\n            raise ValueError(\n                \"Anthropic API key is required. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN environment variable or pass api_key parameter.\"\n            )\n        headers.update(\n            {\n                **auth_header,\n                \"anthropic-version\": \"2023-06-01\",\n                \"anthropic-beta\": ANTHROPIC_FILES_BETA_HEADER,\n            }\n        )\n        return headers\n\n    def get_supported_openai_params(self, model: str) -> list[OpenAICreateFileRequestOptionalParams]:\n        return [\"purpose\"]\n\n    def map_openai_params(\n        self,\n        non_default_params: dict,\n        optional_params: dict,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/anthropic/files/transformation.py#L83-L119","documentation":"Error \"Anthropic API key is required. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN environment variable or pass api_key parameter.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/anthropic/files/transformation.py:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN, or pass api_key to the files call."],"exampleFix":null,"handlingStrategy":null,"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"}