{"record":{"id":"dabd75ab62a4377f","repo":"BerriAI/litellm","slug":"if-llm-api-check-is-set-to-true-llm-api-fail-call","errorCode":null,"errorMessage":"If llm_api_check is set to True, llm_api_fail_call_string must be provided","messagePattern":"If llm_api_check is set to True, llm_api_fail_call_string must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/_types.py","lineNumber":944,"sourceCode":"    llm_api_name: str | None = None\n    llm_api_system_prompt: str | None = None\n    llm_api_fail_call_string: str | None = None\n    reject_as_response: bool | None = Field(\n        default=False,\n        description=\"Return rejected request error message as a string to the user. Default behaviour is to raise an exception.\",\n    )\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def check_llm_api_params(cls, values):\n        llm_api_check: Final = values.get(\"llm_api_check\")\n        if llm_api_check is True:\n            if \"llm_api_name\" not in values or not values[\"llm_api_name\"]:\n                raise ValueError(\"If llm_api_check is set to True, llm_api_name must be provided\")\n            if \"llm_api_system_prompt\" not in values or not values[\"llm_api_system_prompt\"]:\n                raise ValueError(\"If llm_api_check is set to True, llm_api_system_prompt must be provided\")\n            if \"llm_api_fail_call_string\" not in values or not values[\"llm_api_fail_call_string\"]:\n                raise ValueError(\"If llm_api_check is set to True, llm_api_fail_call_string must be provided\")\n        return values\n\n\n######### Request Class Definition ######\nclass ProxyChatCompletionRequest(LiteLLMPydanticObjectBase):\n    \"\"\"\n    Pydantic model for chat completion requests that includes both OpenAI standard fields\n    and LiteLLM-specific parameters. This replaces the previous TypedDict version.\n    \"\"\"\n\n    # Required fields (from ChatCompletionRequest)\n    model: str\n    messages: list[AllMessageValues]\n\n    # Standard OpenAI completion parameters (all optional)\n    frequency_penalty: float | None = None\n    logit_bias: dict[str, float] | None = None\n    logprobs: bool | None = None","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/_types.py#L926-L962","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/_types.py:944 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide llm_api_fail_call_string when llm_api_check is True, or disable the check."],"exampleFix":"llm_api_fail_call_string='FAIL'","handlingStrategy":"validation","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-14T05:17:10.506Z"}