{"record":{"id":"b4b58f1d26610755","repo":"BerriAI/litellm","slug":"if-llm-api-check-is-set-to-true-llm-api-name-must","errorCode":null,"errorMessage":"If llm_api_check is set to True, llm_api_name must be provided","messagePattern":"If llm_api_check is set to True, llm_api_name must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/_types.py","lineNumber":940,"sourceCode":"class LiteLLMPromptInjectionParams(LiteLLMPydanticObjectBase):\n    heuristics_check: bool = False\n    vector_db_check: bool = False\n    llm_api_check: bool = False\n    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","sourceCodeStart":922,"sourceCodeEnd":958,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/_types.py#L922-L958","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/_types.py:940 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide llm_api_name when llm_api_check is True, or set llm_api_check to False."],"exampleFix":"llm_api_check=True, llm_api_name='my_check'","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"}