BerriAI/litellm · error · ValueError
If llm_api_check is set to True, llm_api_name must be provid
Error message
If llm_api_check is set to True, llm_api_name must be provided
What it means
Pydantic model_validator for LiteLLMPromptInjectionParams: llm_api_check=True enables LLM-based prompt-injection checking, which cannot run without the named API; the cross-field validator rejects the config at model construction.
Source
Thrown at litellm/proxy/_types.py:940
class LiteLLMPromptInjectionParams(LiteLLMPydanticObjectBase):
heuristics_check: bool = False
vector_db_check: bool = False
llm_api_check: bool = False
llm_api_name: str | None = None
llm_api_system_prompt: str | None = None
llm_api_fail_call_string: str | None = None
reject_as_response: bool | None = Field(
default=False,
description="Return rejected request error message as a string to the user. Default behaviour is to raise an exception.",
)
@model_validator(mode="before")
@classmethod
def check_llm_api_params(cls, values):
llm_api_check: Final = values.get("llm_api_check")
if llm_api_check is True:
if "llm_api_name" not in values or not values["llm_api_name"]:
raise ValueError("If llm_api_check is set to True, llm_api_name must be provided")
if "llm_api_system_prompt" not in values or not values["llm_api_system_prompt"]:
raise ValueError("If llm_api_check is set to True, llm_api_system_prompt must be provided")
if "llm_api_fail_call_string" not in values or not values["llm_api_fail_call_string"]:
raise ValueError("If llm_api_check is set to True, llm_api_fail_call_string must be provided")
return values
######### Request Class Definition ######
class ProxyChatCompletionRequest(LiteLLMPydanticObjectBase):
"""
Pydantic model for chat completion requests that includes both OpenAI standard fields
and LiteLLM-specific parameters. This replaces the previous TypedDict version.
"""
# Required fields (from ChatCompletionRequest)
model: str
messages: list[AllMessageValues]
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Provide llm_api_name when llm_api_check is True, or set llm_api_check to False.
Example fix
llm_api_check=True, llm_api_name='my_check'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/_types.py:940 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/b4b58f1d26610755.
Report an issue: GitHub.