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: str

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. 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
  2. Or pass the key explicitly in config.yaml under the guardrail's litellm_params: api_key: os.environ/CS_AIDR_TOKEN
  3. Verify visibility from inside the service context: printenv CS_AIDR_TOKEN in the same container/pod
  4. 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

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


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/4bee4a340cd44a30. Report an issue: GitHub.