{"record":{"id":"b6f56865d4f179bc","repo":"BerriAI/litellm","slug":"anthropic-api-key-or-anthropic-auth-token-is-requi","errorCode":null,"errorMessage":"ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API","messagePattern":"ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/anthropic/skills/transformation.py","lineNumber":46,"sourceCode":"\n    @property\n    def custom_llm_provider(self) -> LlmProviders:\n        return LlmProviders.ANTHROPIC\n\n    def validate_environment(self, headers: dict, litellm_params: GenericLiteLLMParams | None) -> dict:\n        \"\"\"Add Anthropic-specific headers\"\"\"\n        from litellm.llms.anthropic.common_utils import AnthropicModelInfo\n\n        # Get API key from litellm_params if available\n        api_key = None\n        api_base = None\n        if litellm_params is not None:\n            api_key = litellm_params.api_key\n            api_base = litellm_params.api_base\n\n        auth_header: Final = AnthropicModelInfo.get_auth_header(api_key, api_base)\n        if auth_header is None:\n            raise ValueError(\"ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API\")\n\n        headers.update(auth_header)\n        headers[\"anthropic-version\"] = \"2023-06-01\"\n\n        # Add beta header for skills API\n        from litellm.constants import ANTHROPIC_SKILLS_API_BETA_VERSION\n\n        if \"anthropic-beta\" not in headers:\n            headers[\"anthropic-beta\"] = ANTHROPIC_SKILLS_API_BETA_VERSION\n        elif isinstance(headers[\"anthropic-beta\"], list):\n            if ANTHROPIC_SKILLS_API_BETA_VERSION not in headers[\"anthropic-beta\"]:\n                headers[\"anthropic-beta\"].append(ANTHROPIC_SKILLS_API_BETA_VERSION)\n        elif isinstance(headers[\"anthropic-beta\"], str):\n            if ANTHROPIC_SKILLS_API_BETA_VERSION not in headers[\"anthropic-beta\"]:\n                headers[\"anthropic-beta\"] = [\n                    headers[\"anthropic-beta\"],\n                    ANTHROPIC_SKILLS_API_BETA_VERSION,\n                ]","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/anthropic/skills/transformation.py#L28-L64","documentation":"Credential validation when building headers for the Anthropic Skills API. The transformation pulls api_key/api_base from litellm_params, resolves an auth header via AnthropicModelInfo.get_auth_header, and raises when no credential is available. The Skills API is Anthropic-direct and always requires ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.","triggerScenarios":"Invoking a Skills API operation through the pass-through without api_key in litellm_params and without either env var set in the process. Setting only api_base (e.g. a proxy URL) without a key still fails.","commonSituations":"Corporate proxy setups where the key lives on the proxy but the client still sends one; fresh environments without the Anthropic secret; skills beta features exercised before credentials were configured.","solutions":["export ANTHROPIC_API_KEY=sk-ant-... or ANTHROPIC_AUTH_TOKEN=... in the calling process.","Or set litellm_params.api_key on the skills request.","Verify with a quick env check before first use in scripts/CI."],"exampleFix":"# before\nresult = skills_handler.list_skills(litellm_params=GenericLiteLLMParams())  # no key\n\n# after\nimport os\nos.environ[\"ANTHROPIC_API_KEY\"] = \"sk-ant-...\"\nresult = skills_handler.list_skills(litellm_params=GenericLiteLLMParams(api_key=\"sk-ant-...\"))","handlingStrategy":"validation","validationCode":"import os\n\ndef skills_api_ready() -> bool:\n    return bool(os.getenv(\"ANTHROPIC_API_KEY\") or os.getenv(\"ANTHROPIC_AUTH_TOKEN\"))","typeGuard":null,"tryCatchPattern":"try:\n    result = skills_endpoint_call(...)\nexcept ValueError as e:\n    if \"Skills API\" in str(e) and \"required\" in str(e):\n        return http_error(503, \"skills feature requires Anthropic credentials\")\n    raise","preventionTips":["Check env credentials at startup before enabling skills endpoints.","Route skills traffic through the proxy when clients lack their own keys.","Use the same secret-injection mechanism as the main Anthropic provider config."],"tags":["anthropic","auth","api-key","skills","environment"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}