{"record":{"id":"188ebf98069e05bf","repo":"BerriAI/litellm","slug":"xecguard-api-key-is-required-set-xecguard-api-key","errorCode":null,"errorMessage":"XecGuard API key is required. Set XECGUARD_API_KEY in the environment or pass api_key in the guardrail config.","messagePattern":"XecGuard API key is required\\. Set XECGUARD_API_KEY in the environment or pass api_key in the guardrail config\\.","errorType":"exception","errorClass":"XecGuardMissingCredentials","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py","lineNumber":97,"sourceCode":"\nclass XecGuardMissingCredentials(Exception):\n    pass\n\n\nclass XecGuardGuardrail(CustomGuardrail):\n    def __init__(\n        self,\n        api_key: str | None = None,\n        api_base: str | None = None,\n        xecguard_model: str | None = None,\n        policy_names: list[str] | None = None,\n        block_on_error: bool | None = None,\n        grounding_strictness: str | None = None,\n        **kwargs: Any,\n    ) -> None:\n        self.api_key = api_key or os.environ.get(\"XECGUARD_API_KEY\")\n        if not self.api_key:\n            raise XecGuardMissingCredentials(\n                \"XecGuard API key is required. \"\n                \"Set XECGUARD_API_KEY in the \"\n                \"environment or pass api_key in \"\n                \"the guardrail config.\"\n            )\n\n        self.api_base = (api_base or os.environ.get(\"XECGUARD_API_BASE\") or _DEFAULT_API_BASE).rstrip(\"/\")\n\n        self.xecguard_model = xecguard_model or _DEFAULT_MODEL\n        self.policy_names = policy_names\n\n        if block_on_error is None:\n            env: Final = os.environ.get(\"XECGUARD_BLOCK_ON_ERROR\", \"true\")\n            self.block_on_error = env.lower() in (\n                \"true\",\n                \"1\",\n                \"yes\",\n            )","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py#L79-L115","documentation":"Error \"XecGuard API key is required. Set XECGUARD_API_KEY in the environment or pass api_key in the guardrail config.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py:97 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the XECGUARD_API_KEY environment variable.","Or pass api_key in the xecguard guardrail config."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}