Skip to main content
Every exception the SDK raises inherits from DeuteroError. Errors returned by the API are APIError subclasses, chosen by HTTP status code.

Exception hierarchy

Any other non-2xx status raises a plain APIError.
deutero.ConnectionError and deutero.TimeoutError shadow Python’s built-ins of the same name. Import them qualified (import deutero and then deutero.TimeoutError) if you also use the built-ins.

What’s on an APIError

str
A readable summary, such as HTTP 404: Study not found. Field-level validation errors are joined into one line, for example name: field required; max_responses: must be positive.
int
The HTTP status code.
Any
The parsed response body: a dict for JSON responses, otherwise the raw text. This is where the details live for refusals such as a blocked publish or an invalid flow.
str | None
The x-request-id response header, if present. Include it when contacting support.

Common cases

studies.publish raises ConflictError when the plan’s open-study limit, credits or validation block it. e.body carries the refusal code, the issues and the validation_run_id. If only methodological issues remain, publish again with acknowledge_validation_run_id. See Publish.
graph.set and graph.patch save nothing unless the result is valid. An invalid flow raises ValidationError with every problem in e.body. A stale expected_graph_version raises ConflictError: re-read the flow and retry. See Safe concurrent edits.
InsufficientCreditsError is raised when the organization can’t cover an operation, such as a simulation. Check your balance with client.credits.get_balance().
Back off and retry. studies.draft_from_site also returns 429 once a site’s draft allowance is used up.
Drafting, question generation and validation can take a minute or more. If you see TimeoutError, raise the client timeout.

Retrying

The SDK doesn’t retry failed requests. To retry connection failures, pass an httpx client with a retrying transport:
For 429 and 5xx responses, wrap calls in your own backoff, for example with tenacity: