BerriAI/litellm · error
Deepinfra API key is required. Please set…
Error message
Deepinfra API key is required. Please set 'DEEPINFRA_API_KEY' environment variable
What it means
Credential guard in the DeepInfra rerank config: api_key was None and the DEEPINFRA_API_KEY environment secret is unset, so the rerank request would be unauthorized and is rejected before dispatch.
Solutions
- Set the DEEPINFRA_API_KEY environment variable before making the call, e.g. export DEEPINFRA_API_KEY=<your-key>.
- Alternatively pass the credential directly via the api_key parameter in the litellm call.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/llms/deepinfra/rerank/transformation.py:75 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/3f7a64e5aee8e17b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/deepinfra/rerank/transformation.py:75
# Remove any trailing slashes for consistency, then add one
api_base_clean = api_base_clean.rstrip("/") + "/"
# Compose the full endpoint
return f"{api_base_clean}inference/{model}"
def validate_environment(
self,
headers: dict,
model: str,
api_key: str | None = None,
optional_params: dict | None = None,
) -> dict:
if api_key is None:
api_key = get_secret_str("DEEPINFRA_API_KEY")
if api_key is None:
raise ValueError("Deepinfra API key is required. Please set 'DEEPINFRA_API_KEY' environment variable")
default_headers: Final = {
"Authorization": f"Bearer {api_key}",
"accept": "application/json",
"content-type": "application/json",
}
# If 'Authorization' is provided in headers, it overrides the default.
if "Authorization" in headers:
default_headers["Authorization"] = headers["Authorization"]
# Merge other headers, overriding any default ones except Authorization
return {**default_headers, **headers}
def map_cohere_rerank_params(
self,
non_default_params: dict,
model: str,View on GitHub (pinned to 77b7c6c40c)