BerriAI/litellm · error · ValueError
LINKUP_API_KEY is not set. Set `LINKUP_API_KEY` environment…
Error message
LINKUP_API_KEY is not set. Set `LINKUP_API_KEY` environment variable.
What it means
The Linkup search transformation authenticates with a Bearer token. resolve_server_api_key checks the caller-supplied api_key and the LINKUP_API_KEY environment variable; when neither yields a key, validate_environment raises ValueError before any search request is sent, because the Linkup API cannot be called anonymously.
Solutions
- Set the env var: export LINKUP_API_KEY=lk-... in the process making the call
- Or pass the key explicitly as api_key on the search call
- Add LINKUP_API_KEY to your deployment secrets (.env, docker env, k8s secret)
- Confirm with printenv LINKUP_API_KEY from the same runtime
Example fix
# before results = litellm.search(query="latest ai news", provider="linkup") # ValueError: LINKUP_API_KEY is not set # after os.environ["LINKUP_API_KEY"] = "lk-..." results = litellm.search(query="latest ai news", provider="linkup")
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv("LINKUP_API_KEY"):
raise SystemExit("Set LINKUP_API_KEY before using Linkup search")
# then: litellm.search(query=..., provider="linkup") will not raise on auth setup Try / catch
try:
results = litellm.search(query=q, provider="linkup")
except ValueError as e:
if "LINKUP_API_KEY is not set" in str(e):
raise ConfigError("Missing LINKUP_API_KEY environment variable") from e
raise Prevention
- Fail fast at startup when search providers are enabled but their keys are absent
- Keep provider API keys in a single validated secrets map loaded at boot
- Add LINKUP_API_KEY to deployment secret manifests and CI checks
When it happens
Trigger: Any Linkup-backed web search (e.g. litellm.search / search provider 'linkup' or a model routed to linkup search) invoked without an api_key parameter and without LINKUP_API_KEY present in the environment.
Common situations: Env var missing in the deployed environment or CI; key stored under a different name (LINKUP_KEY, LINKUP_API_TOKEN); local shell has it but the server process does not.
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
Related errors
- BRAVE_API_KEY is not set. Set `BRAVE_API_KEY` environment…
- BFL_API_KEY is not set. Please set it via environment…
- Missing api_key, make sure you pass in your api key
- XAI API key is required. Set api_key, litellm.xai_key…
- api_key is required
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/14d5d8466ddb7703.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/linkup/search/transformation.py:70
def validate_environment(
self,
headers: dict,
api_key: str | None = None,
api_base: str | None = None,
**kwargs,
) -> dict:
"""
Validate environment and return headers.
"""
api_key = self.resolve_server_api_key(
caller_api_key=api_key,
caller_api_base=api_base,
key_env_vars=("LINKUP_API_KEY",),
base_env_var="LINKUP_API_BASE",
default_api_base=self.LINKUP_API_BASE,
)
if not api_key:
raise ValueError("LINKUP_API_KEY is not set. Set `LINKUP_API_KEY` environment variable.")
headers["Authorization"] = f"Bearer {api_key}"
headers["Content-Type"] = "application/json"
return headers
def get_complete_url(
self,
api_base: str | None,
optional_params: dict,
data: dict | list[dict] | None = None,
**kwargs,
) -> str:
"""
Get complete URL for Search endpoint.
"""
api_base = api_base or get_secret_str("LINKUP_API_BASE") or self.LINKUP_API_BASE
# Append "/search" to the api base if it's not already there
if not api_base.endswith("/search"):View on GitHub (pinned to 77b7c6c40c)