Skip to main content
AsyncNdiClient exposes the same namespaces and methods as NdiClient, using await for network calls. Use it for web services, concurrent document processing, or any application that already runs an asyncio event loop.

Basic usage

The async client mirrors the sync client. For example, client.documents.parse(...) becomes await client.documents.parse(...), and client.jobs.iter_all() is consumed with async for.

Process documents concurrently

Share one client across tasks. Each operation creates its own job, and each jobs.wait polls independently.

Limit concurrency

Use an asyncio.Semaphore when processing a large batch. This bounds the number of jobs submitted at once and helps your application stay within its NDI concurrent-job limit.
The semaphore limits the complete upload, submission, and wait cycle. If you only want to limit submission, release it before jobs.wait.

Handle partial batch failures

By default, asyncio.gather raises when one task fails. Use return_exceptions=True when each document should succeed or fail independently.
See Error handling for the typed exceptions returned by failed HTTP requests and jobs.

Close the client

Prefer async with, which closes the SDK-owned httpx.AsyncClient. If you cannot use a context manager, call await client.aclose().
If you pass your own httpx.AsyncClient, you own its lifecycle.

When to use async

Use AsyncNdiClient

Concurrent batches, FastAPI or other async services, and applications that already use asyncio.

Use NdiClient

One-off scripts, notebooks, and sequential processing where async would add unnecessary complexity.

Next steps