BerriAI/litellm · error · PromptGuardMissingCredentials
PromptGuard API key is required. Set PROMPTGUARD_API_KEY in
Error message
PromptGuard API key is required. Set PROMPTGUARD_API_KEY in the environment or pass api_key in the guardrail config.
What it means
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.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py:53
class PromptGuardMissingCredentials(Exception):
pass
class PromptGuardGuardrail(CustomGuardrail):
def __init__(
self,
api_key: str | None = None,
api_base: str | None = None,
block_on_error: bool | None = None,
**kwargs: Any,
) -> None:
self.api_key = api_key or os.environ.get(
"PROMPTGUARD_API_KEY",
)
if not self.api_key:
raise PromptGuardMissingCredentials(
"PromptGuard API key is required. "
"Set PROMPTGUARD_API_KEY in the "
"environment or pass api_key in "
"the guardrail config."
)
self.api_base = (api_base or os.environ.get("PROMPTGUARD_API_BASE") or _DEFAULT_API_BASE).rstrip("/")
if block_on_error is None:
env: Final = os.environ.get("PROMPTGUARD_BLOCK_ON_ERROR", "true")
self.block_on_error = env.lower() in (
"true",
"1",
"yes",
)
else:
self.block_on_error = block_on_error
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set the PROMPTGUARD_API_KEY environment variable.
- Or pass api_key in the promptguard guardrail config.
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py:53 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/cf9d32e738a17e1d.
Report an issue: GitHub.