Judgeval Python SDKResponse Types
JudgmentAPIError
Primary exception raised when API operations fail
Primary exception raised when API operations fail due to network, authentication, or server issues.
messagerequired:str
Human-readable error description
status_code:int
HTTP status code from the failed API request
response_data:Dict[str, Any]
Additional details from the API response, if available
Recommended Error Handling
- 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 JudgmentClient, JudgmentAPIError
client = JudgmentClient()
try:
result = client.evaluate(examples=[...], scorers=[...])
except JudgmentAPIError as e:
print(f"API Error: {e.message}")
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
try:
# SDK operations
result = client.evaluate([...])
except JudgmentAPIError as api_error:
# Handle API-specific errors
logger.error(f"API error: {api_error.message}")
if api_error.status_code >= 500:
# Retry logic for server errors
pass
except ConnectionError:
# Handle network issues
logger.error("Network connection failed")
except Exception as e:
# Handle unexpected errors
logger.error(f"Unexpected error: {e}")