Judgeval Python-v1 SDKResponse Types

JudgmentAPIError

Primary exception raised when API operations fail

Primary exception raised when API operations fail due to network, authentication, or server issues.

status_coderequired

:int

HTTP status code from the failed API request

detailrequired

:str
Human-readable error description

response

:Optional[Response]

The HTTP response object from the failed request, if available

  • Authentication failures (401): Invalid API key or organization ID
  • Rate limiting (429): Too many requests in a short time period
  • Server errors (500+): Temporary issues with the Judgment platform
  • Bad requests (400): Invalid parameters or malformed data
from judgeval import Judgeval
from judgeval.exceptions import JudgmentAPIError

client = Judgeval(project_name="default_project")

try:
    results = client.evaluation.create().run(
        examples=[...],
        scorers=[...]
    )
except JudgmentAPIError as e:
    print(f"API Error: {e.detail}")
    if e.status_code == 401:
        print("Check your API key and organization ID")
    elif e.status_code == 429:
        print("Rate limited - try again later")
    else:
        print(f"Server error (status {e.status_code})")

Exception Hierarchy

from judgeval.exceptions import JudgmentAPIError
from httpx import HTTPError

try:
    # SDK operations
    results = client.evaluation.create().run([...])
except JudgmentAPIError as api_error:
    # Handle API-specific errors
    logger.error(f"API error: {api_error.detail}")
    if api_error.status_code >= 500:
        # Retry logic for server errors
        pass
except HTTPError:
    # Handle network issues (JudgmentAPIError extends HTTPError)
    logger.error("Network connection failed")
except Exception as e:
    # Handle unexpected errors
    logger.error(f"Unexpected error: {e}")