BerriAI/litellm · error · ValueError

If llm_api_check is set to True, llm_api_fail_call_string mu

Error message

If llm_api_check is set to True, llm_api_fail_call_string must be provided

What it means

Pydantic model_validator on the guardrail LLM-API settings rejecting a config where llm_api_check is True but llm_api_name (and the companion fail-call string) were not supplied. LiteLLM cannot build an LLM-based rejection check without knowing which model to call, so the whole settings object is rejected at load time rather than failing per-request later.

Source

Thrown at litellm/proxy/_types.py:944

    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]

    # Standard OpenAI completion parameters (all optional)
    frequency_penalty: float | None = None
    logit_bias: dict[str, float] | None = None
    logprobs: bool | None = None

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide llm_api_fail_call_string when llm_api_check is True, or disable the check.

Example fix

llm_api_fail_call_string='FAIL'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/_types.py:944 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/dabd75ab62a4377f. Report an issue: GitHub.