BerriAI/litellm · error · ValueError

ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Sk

Error message

ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API

What it means

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.

Source

Thrown at litellm/llms/anthropic/skills/transformation.py:46

    @property
    def custom_llm_provider(self) -> LlmProviders:
        return LlmProviders.ANTHROPIC

    def validate_environment(self, headers: dict, litellm_params: GenericLiteLLMParams | None) -> dict:
        """Add Anthropic-specific headers"""
        from litellm.llms.anthropic.common_utils import AnthropicModelInfo

        # Get API key from litellm_params if available
        api_key = None
        api_base = None
        if litellm_params is not None:
            api_key = litellm_params.api_key
            api_base = litellm_params.api_base

        auth_header: Final = AnthropicModelInfo.get_auth_header(api_key, api_base)
        if auth_header is None:
            raise ValueError("ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API")

        headers.update(auth_header)
        headers["anthropic-version"] = "2023-06-01"

        # Add beta header for skills API
        from litellm.constants import ANTHROPIC_SKILLS_API_BETA_VERSION

        if "anthropic-beta" not in headers:
            headers["anthropic-beta"] = ANTHROPIC_SKILLS_API_BETA_VERSION
        elif isinstance(headers["anthropic-beta"], list):
            if ANTHROPIC_SKILLS_API_BETA_VERSION not in headers["anthropic-beta"]:
                headers["anthropic-beta"].append(ANTHROPIC_SKILLS_API_BETA_VERSION)
        elif isinstance(headers["anthropic-beta"], str):
            if ANTHROPIC_SKILLS_API_BETA_VERSION not in headers["anthropic-beta"]:
                headers["anthropic-beta"] = [
                    headers["anthropic-beta"],
                    ANTHROPIC_SKILLS_API_BETA_VERSION,
                ]

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. export ANTHROPIC_API_KEY=sk-ant-... or ANTHROPIC_AUTH_TOKEN=... in the calling process.
  2. Or set litellm_params.api_key on the skills request.
  3. Verify with a quick env check before first use in scripts/CI.

Example fix

# before
result = skills_handler.list_skills(litellm_params=GenericLiteLLMParams())  # no key

# after
import os
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..."
result = skills_handler.list_skills(litellm_params=GenericLiteLLMParams(api_key="sk-ant-..."))
Defensive patterns

Strategy: validation

Validate before calling

import os

def skills_api_ready() -> bool:
    return bool(os.getenv("ANTHROPIC_API_KEY") or os.getenv("ANTHROPIC_AUTH_TOKEN"))

Try / catch

try:
    result = skills_endpoint_call(...)
except ValueError as e:
    if "Skills API" in str(e) and "required" in str(e):
        return http_error(503, "skills feature requires Anthropic credentials")
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/b6f56865d4f179bc. Report an issue: GitHub.