BerriAI/litellm · error · Exception
PromptInjectionDetection: Invalid LLM API Name. LLM API Name
Error message
PromptInjectionDetection: Invalid LLM API Name. LLM API Name must be a 'model_name' in 'model_list'.
What it means
Error "PromptInjectionDetection: Invalid LLM API Name. LLM API Name must be a 'model_name' in 'model_list'." thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/hooks/prompt_injection_detection.py:93
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:
for prep in self.prepositions:
phrase = " ".join(filter(None, [verb, adj, prep])).strip()
if len(phrase.split()) > 2: # additional check to ensure more than 2 words
combinations.append(phrase.lower())
return combinations
def check_user_input_similarity(
self,
user_input: str,
similarity_threshold: float = DEFAULT_PROMPT_INJECTION_SIMILARITY_THRESHOLD,
) -> bool:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set llm_api_name to a model_name that exists in the proxy model_list.
- Check for typos in the configured LLM API name.
When it happens
Trigger: Thrown at litellm/proxy/hooks/prompt_injection_detection.py:93 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/28738b5c3bd60539.
Report an issue: GitHub.