Skip to main content
Every HTTP, connection, and job failure raised by ndi-sdk inherits from NdiError. Catch a specific subclass when your application can recover from that failure, or catch NdiError at the outer SDK boundary. Client configuration mistakes use Python’s ValueError. For example, creating a client without an API key or passing an empty idempotency_key fails before an HTTP request is sent.

Exception hierarchy

Handle common failures

HTTP status errors

NdiStatusError means the server returned a non-success HTTP response. It exposes: Handle error codes when behavior differs within one HTTP status:
ErrorCode is open-ended. Unknown codes remain usable values instead of causing response validation to fail. unsupported_file_type is an InvalidRequestError with status 422. It is returned synchronously by an upload boundary or document-operation start, so there is no failed job to poll. A rejected workspace upload also creates no file. Check exc.code == ErrorCode.UNSUPPORTED_FILE_TYPE; do not retry the same request or maintain a separate client-side format allowlist.

Job errors are different

An HTTP request can succeed while the asynchronous job later fails. JobFailedError therefore contains the terminal job, including job.error.code, job.error.message, and any job-specific detail.
JobTimeoutError only means the local jobs.wait budget expired. The job continues server-side and can be read again with client.jobs.get(job_id).

Connection and HTTP timeouts

NdiConnectionError means no response was produced because of DNS, TLS, connection, or transport failure. NdiTimeoutError is its timeout-specific subclass. The client timeout defaults to 60 seconds per HTTP request:
This HTTP timeout is separate from client.jobs.wait(..., timeout=600), which sets the total polling budget.

Automatic retries

The SDK retries safe requests after connection failures, HTTP 429, and 5xx responses. The default RetryPolicy makes at most three attempts with exponential backoff and full jitter. The defaults are initial_backoff=0.5 seconds and max_backoff=8.0 seconds. A valid Retry-After response header takes precedence.
The SDK only retries a request when replay is safe. Read methods are idempotent, and job-creating methods automatically mint an Idempotency-Key. State conflicts (409) and invalid requests are not retried. Streaming jobs.events connections are not retried automatically; reconnect with last_event_id when needed.

Best practices

Catch specific exceptions

Recover from known conditions such as rate limits or missing resources, then let unexpected SDK errors reach your application boundary.

Log the request ID

Include request_id, status_code, and code in logs without recording API keys or document contents.

Distinguish HTTP and job failure

A successful submission can still produce a failed job. Handle both NdiStatusError and JobFailedError.

Preserve idempotency

Let the SDK mint keys, or reuse your explicit key when replaying the same job-creating request.

Next steps