{"record":{"id":"cf9d32e738a17e1d","repo":"BerriAI/litellm","slug":"promptguard-api-key-is-required-set-promptguard-a","errorCode":null,"errorMessage":"PromptGuard API key is required. Set PROMPTGUARD_API_KEY in the environment or pass api_key in the guardrail config.","messagePattern":"PromptGuard API key is required\\. Set PROMPTGUARD_API_KEY in the environment or pass api_key in the guardrail config\\.","errorType":"exception","errorClass":"PromptGuardMissingCredentials","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py","lineNumber":53,"sourceCode":"\n\nclass PromptGuardMissingCredentials(Exception):\n    pass\n\n\nclass PromptGuardGuardrail(CustomGuardrail):\n    def __init__(\n        self,\n        api_key: str | None = None,\n        api_base: str | None = None,\n        block_on_error: bool | None = None,\n        **kwargs: Any,\n    ) -> None:\n        self.api_key = api_key or os.environ.get(\n            \"PROMPTGUARD_API_KEY\",\n        )\n        if not self.api_key:\n            raise PromptGuardMissingCredentials(\n                \"PromptGuard API key is required. \"\n                \"Set PROMPTGUARD_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(\"PROMPTGUARD_API_BASE\") or _DEFAULT_API_BASE).rstrip(\"/\")\n\n        if block_on_error is None:\n            env: Final = os.environ.get(\"PROMPTGUARD_BLOCK_ON_ERROR\", \"true\")\n            self.block_on_error = env.lower() in (\n                \"true\",\n                \"1\",\n                \"yes\",\n            )\n        else:\n            self.block_on_error = block_on_error\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py#L35-L71","documentation":"Error \"PromptGuard API key is required. Set PROMPTGUARD_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/promptguard/promptguard.py:53 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the PROMPTGUARD_API_KEY environment variable.","Or pass api_key in the promptguard 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-14T05:17:10.506Z"}