From 9cf52d8006489220dc1be4346669c8d8b791a066 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 22 Apr 2026 16:50:49 -0700 Subject: [PATCH] add EvalFailedError exception with status_code 422 --- litellm/exceptions.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/litellm/exceptions.py b/litellm/exceptions.py index 51810c5643f..4e8d3828a3f 100644 --- a/litellm/exceptions.py +++ b/litellm/exceptions.py @@ -9,7 +9,7 @@ ## LiteLLM versions of the OpenAI Exception Types -from typing import Optional +from typing import Any, Optional import httpx import openai @@ -502,6 +502,25 @@ class ContentPolicyViolationError(BadRequestError): # type: ignore return _message +class EvalFailedError(Exception): + """Raised when an LLM-judge eval fails to meet the acceptance threshold.""" + + status_code: int = 422 + + def __init__( + self, + message: str, + eval_result: Any, + model: str = "", + llm_provider: str = "", + ): + self.eval_result = eval_result + self.model = model + self.llm_provider = llm_provider + self.status_code = 422 + super().__init__(message) + + class ServiceUnavailableError(openai.APIStatusError): # type: ignore def __init__( self,