{"record":{"id":"7e9cc8474001077f","repo":"BerriAI/litellm","slug":"couldn-t-get-prompt-security-api-base-or-key-eith","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"exception","errorClass":"PromptSecurityGuardrailMissingSecrets","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py","lineNumber":69,"sourceCode":"        self.user = user or os.environ.get(\"PROMPT_SECURITY_USER\")\n        self.system_prompt = system_prompt or os.environ.get(\"PROMPT_SECURITY_SYSTEM_PROMPT\")\n\n        # Configure whether to check tool/function results for indirect prompt injection\n        # Default: False (Filter out tool/function messages)\n        # True: Transform to \"other\" role and send to API\n        if check_tool_results is None:\n            check_tool_results_env: Final = os.environ.get(\"PROMPT_SECURITY_CHECK_TOOL_RESULTS\", \"false\").lower()\n            self.check_tool_results = check_tool_results_env in (\"true\", \"1\", \"yes\")\n        else:\n            self.check_tool_results = check_tool_results\n\n        if not self.api_key or not self.api_base:\n            msg: Final = (\n                \"Couldn't get Prompt Security api base or key, \"\n                \"either set the `PROMPT_SECURITY_API_BASE` and `PROMPT_SECURITY_API_KEY` in the environment \"\n                \"or pass them as parameters to the guardrail in the config file\"\n            )\n            raise PromptSecurityGuardrailMissingSecrets(msg)\n\n        # Configuration for file sanitization\n        self.max_poll_attempts = 30  # Maximum number of polling attempts\n        self.poll_interval = 2  # Seconds between polling attempts\n\n        super().__init__(**kwargs)\n\n    def supports_scan_only_tool_results(self) -> bool:\n        return self.check_tool_results\n\n    @log_guardrail_information\n    async def apply_guardrail(\n        self,\n        inputs: GenericGuardrailAPIInputs,\n        request_data: dict,\n        input_type: Literal[\"request\", \"response\"],\n        logging_obj: Optional[\"LiteLLMLoggingObj\"] = None,\n    ) -> GenericGuardrailAPIInputs:","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py#L51-L87","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/prompt_security/prompt_security.py:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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"}