BerriAI/litellm · error · ValueError
Anthropic API key is required. Set ANTHROPIC_API_KEY or…
Error message
Anthropic API key is required. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN environment variable or pass api_key parameter.
What it means
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.
Solutions
- Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN, or pass api_key to the files call.
When it happens
Trigger: Thrown at litellm/llms/anthropic/files/transformation.py:101 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/9ead571312188c44.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/anthropic/files/transformation.py:101
message=error_message,
headers=(cast(httpx.Headers, headers) if isinstance(headers, dict) else headers),
)
def validate_environment(
self,
headers: dict,
model: str,
messages: list,
optional_params: dict,
litellm_params: dict,
api_key: str | None = None,
api_base: str | None = None,
) -> dict:
if api_base is None and isinstance(litellm_params, dict):
api_base = litellm_params.get("api_base")
auth_header: Final = AnthropicModelInfo.get_auth_header(api_key, api_base)
if auth_header is None:
raise ValueError(
"Anthropic API key is required. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN environment variable or pass api_key parameter."
)
headers.update(
{
**auth_header,
"anthropic-version": "2023-06-01",
"anthropic-beta": ANTHROPIC_FILES_BETA_HEADER,
}
)
return headers
def get_supported_openai_params(self, model: str) -> list[OpenAICreateFileRequestOptionalParams]:
return ["purpose"]
def map_openai_params(
self,
non_default_params: dict,
optional_params: dict,View on GitHub (pinned to 77b7c6c40c)