BerriAI/litellm · error · PromptSecurityGuardrailMissingSecrets
Couldn't get Prompt Security api base or key, either set the
Error message
Couldn't get Prompt Security api base or key, either set the `PROMPT_SECURITY_API_BASE` and `PROMPT_SECURITY_API_KEY` in the environment or pass them as parameters to the guardrail in the config file
What it means
Error "Couldn't get Prompt Security api base or key, either set the `PROMPT_SECURITY_API_BASE` and `PROMPT_SECURITY_API_KEY` in the environment or pass them as parameters to the guardrail in the config file" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py:69
self.user = user or os.environ.get("PROMPT_SECURITY_USER")
self.system_prompt = system_prompt or os.environ.get("PROMPT_SECURITY_SYSTEM_PROMPT")
# Configure whether to check tool/function results for indirect prompt injection
# Default: False (Filter out tool/function messages)
# True: Transform to "other" role and send to API
if check_tool_results is None:
check_tool_results_env: Final = os.environ.get("PROMPT_SECURITY_CHECK_TOOL_RESULTS", "false").lower()
self.check_tool_results = check_tool_results_env in ("true", "1", "yes")
else:
self.check_tool_results = check_tool_results
if not self.api_key or not self.api_base:
msg: Final = (
"Couldn't get Prompt Security api base or key, "
"either set the `PROMPT_SECURITY_API_BASE` and `PROMPT_SECURITY_API_KEY` in the environment "
"or pass them as parameters to the guardrail in the config file"
)
raise PromptSecurityGuardrailMissingSecrets(msg)
# Configuration for file sanitization
self.max_poll_attempts = 30 # Maximum number of polling attempts
self.poll_interval = 2 # Seconds between polling attempts
super().__init__(**kwargs)
def supports_scan_only_tool_results(self) -> bool:
return self.check_tool_results
@log_guardrail_information
async def apply_guardrail(
self,
inputs: GenericGuardrailAPIInputs,
request_data: dict,
input_type: Literal["request", "response"],
logging_obj: Optional["LiteLLMLoggingObj"] = None,
) -> GenericGuardrailAPIInputs:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set PROMPT_SECURITY_API_BASE and PROMPT_SECURITY_API_KEY environment variables.
- Or pass api_base and api_key in the prompt_security guardrail's litellm_params.
When it happens
Trigger: Thrown at litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py:69 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/7e9cc8474001077f.
Report an issue: GitHub.