BerriAI/litellm · error · CrowdStrikeAIDRGuardrailMissingSecrets
CrowdStrike AIDR API Key not found. Set CS_AIDR_TOKEN enviro
Error message
CrowdStrike AIDR API Key not found. Set CS_AIDR_TOKEN environment variable or pass it in litellm_params.
What it means
Raised by CrowdStrikeAIDRHandler.__init__ while the LiteLLM proxy instantiates the CrowdStrike AI Detection & Response guardrail: no API key was found either as the api_key constructor argument (wired from litellm_params) or in the CS_AIDR_TOKEN environment variable. LiteLLM fails fast at config-load/startup because the guardrail cannot authenticate guard API calls without the key.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/crowdstrike_aidr/crowdstrike_aidr.py:257
guardrail_name: str,
api_key: str | None = None,
api_base: str | None = None,
**kwargs,
) -> None:
"""
Initializes the CrowdStrikeAIDRHandler.
Args:
guardrail_name (str): The name of the guardrail instance.
api_key (str | None): The CrowdStrike AIDR API key. Reads from CS_AIDR_TOKEN env var if None.
api_base (str | None): The CrowdStrike AIDR API base URL. Reads from CS_AIDR_BASE_URL env var if None.
**kwargs: Additional arguments passed to the CustomGuardrail base class.
"""
self.async_handler = get_async_httpx_client(llm_provider=httpxSpecialProvider.GuardrailCallback)
self.api_key = api_key or os.environ.get("CS_AIDR_TOKEN")
if not self.api_key:
raise CrowdStrikeAIDRGuardrailMissingSecrets(
"CrowdStrike AIDR API Key not found. Set CS_AIDR_TOKEN environment variable or pass it in litellm_params."
)
self.api_base = api_base or os.environ.get("CS_AIDR_BASE_URL")
if not self.api_base:
raise CrowdStrikeAIDRGuardrailMissingSecrets(
"CrowdStrike AIDR API base URL is required. Set CS_AIDR_BASE_URL environment variable or pass it in litellm_params."
)
kwargs.setdefault("supported_event_hooks", list(self.get_supported_event_hooks()))
# Pass relevant kwargs to the parent class
super().__init__(guardrail_name=guardrail_name, **kwargs)
verbose_proxy_logger.debug(
"Initialized CrowdStrike AIDR Guardrail: name=%s, api_base=%s", guardrail_name, self.api_base
)
async def _call_crowdstrike_aidr_guard(
self, payload: dict[str, Any], hook_name: strView on GitHub (pinned to 77b7c6c40c)
Solutions
- Set CS_AIDR_TOKEN in the exact environment the proxy runs in (export CS_AIDR_TOKEN=..., docker -e, k8s secret, systemd Environment=) and restart the proxy
- Or pass the key explicitly in config.yaml under the guardrail's litellm_params: api_key: os.environ/CS_AIDR_TOKEN
- Verify visibility from inside the service context: printenv CS_AIDR_TOKEN in the same container/pod
- Check for typos and empty-string overrides of the variable name
Example fix
# before
guardrails:
- guardrail_id: crowdstrike-aidr
litellm_params:
mode: guardrail_runs_before_llm_call
# after (env var preferred, or inline reference)
# export CS_AIDR_TOKEN=your-token
guardrails:
- guardrail_id: crowdstrike-aidr
litellm_params:
mode: guardrail_runs_before_llm_call
api_key: os.environ/CS_AIDR_TOKEN
api_base: os.environ/CS_AIDR_BASE_URL Defensive patterns
Strategy: validation
Validate before calling
import os
missing = [v for v in ('CS_AIDR_TOKEN', 'CS_AIDR_BASE_URL') if not os.environ.get(v)]
if missing:
raise RuntimeError(f'CrowdStrike AIDR guardrail disabled - unset env vars: {missing}')
# proceed to start the proxy only when the list is empty Try / catch
from litellm.proxy.guardrails.guardrail_hooks.crowdstrike_aidr.crowdstrike_aidr import (
CrowdStrikeAIDRGuardrailMissingSecrets,
)
try:
handler = CrowdStrikeAIDRHandler(guardrail_name='cs-aidr')
except CrowdStrikeAIDRGuardrailMissingSecrets as e:
raise SystemExit(f'guardrail config incomplete: {e}') from e # fail the deploy, not requests Prevention
- Declare CS_AIDR_TOKEN and CS_AIDR_BASE_URL in the deployment manifest next to the image so ad-hoc shells cannot drift
- Add a preflight deploy check asserting all guardrail env vars are non-empty strings
- Dry-run load config.yaml (or call the /guardrails endpoints on a staging instance) before promoting
When it happens
Trigger: Adding a guardrails entry in config.yaml whose litellm_params selects a crowdstrike-aidr hook (e.g. mode: guardrail_runs_before_llm_call) without an api_key, while CS_AIDR_TOKEN is unset in the proxy process; starting the proxy under docker/k8s/systemd where the env var was never injected into the service.
Common situations: Env var exported in an interactive shell but missing in the deployed service; typo in the variable name (e.g. CS_AIDR_API_KEY); an empty-string override (CS_AIDR_TOKEN='') masking a real value; assuming the key is read from the LiteLLM DB or master key instead of the process environment.
Related errors
- CrowdStrike AIDR API base URL is required. Set CS_AIDR_BASE_
- DeepKeep API key is required. Set the `DEEPKEEP_API_KEY` env
- DeepKeep firewall_id is required. Set the `DEEPKEEP_FIREWALL
- DeepKeep API base URL is required. Set the `DEEPKEEP_API_BAS
- OpenAI Moderation: api_key is required. Set OPENAI_API_KEY e
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/4bee4a340cd44a30.
Report an issue: GitHub.