Skip to main content
The SDK raises standard Python exceptions. Here’s how to handle them.

Error Types

HTTP Errors

API failures raise requests.exceptions.HTTPError with the status code and server error message.
Common HTTP status codes:

Validation Errors

Invalid inputs raise ValueError:
Common causes:
  • Empty required fields (dql, agent_run_ids, etc.)
  • Invalid parameter values (limit <= 0, unsupported permission values)
  • Missing API key at initialization

Schema Validation Errors

Invalid JSON schemas raise jsonschema.ValidationError:

Job Failures

When using add_agent_runs(wait=True), failed background jobs raise RuntimeError. The exception message is the server-provided error_message from the job status when available, and falls back to "Job was canceled" otherwise:

Retry Behavior

The SDK automatically retries on server errors (5xx) for agent run uploads (add_agent_runs), with exponential backoff (up to 3 retries by default). Client errors (4xx) are not retried. Other methods do not retry automatically.

Best Practices