BerriAI/litellm · error · Exception
PromptInjectionDetection: Model List not set. Required for P
Error message
PromptInjectionDetection: Model List not set. Required for Prompt Injection detection.
What it means
Error "PromptInjectionDetection: Model List not set. Required for Prompt Injection detection." thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/hooks/prompt_injection_detection.py:82
"and begin afresh",
"and start from scratch",
]
def print_verbose(self, print_statement, level: Literal["INFO", "DEBUG"] = "DEBUG"):
if level == "INFO":
verbose_proxy_logger.info(print_statement)
elif level == "DEBUG":
verbose_proxy_logger.debug(print_statement)
if litellm.set_verbose is True:
print(print_statement) # noqa: T201
def update_environment(self, router: Router | None = None):
self.llm_router = router
if self.prompt_injection_params is not None and self.prompt_injection_params.llm_api_check is True:
if self.llm_router is None:
raise Exception(
"PromptInjectionDetection: Model List not set. Required for Prompt Injection detection."
)
self.print_verbose(
f"model_names: {self.llm_router.model_names}; self.prompt_injection_params.llm_api_name: {self.prompt_injection_params.llm_api_name}"
)
if (
self.prompt_injection_params.llm_api_name is None
or self.prompt_injection_params.llm_api_name not in self.llm_router.model_names
):
raise Exception(
"PromptInjectionDetection: Invalid LLM API Name. LLM API Name must be a 'model_name' in 'model_list'."
)
def generate_injection_keywords(self) -> list[str]:
combinations: Final = []
for verb in self.verbs:
for adj in self.adjectives:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Configure model_list on the proxy so the prompt injection detection model can be resolved.
- Pass the router with a model list to the PromptInjectionDetection hook.
When it happens
Trigger: Thrown at litellm/proxy/hooks/prompt_injection_detection.py:82 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/9e18d2e021f6ec22.
Report an issue: GitHub.