import asyncio
from ndi_sdk import AsyncNdiClient
async def parse_one(client: AsyncNdiClient, name: str) -> str:
upload = await client.documents.create_upload(name)
job = await client.documents.parse(upload, wait_seconds=30)
job = await client.jobs.wait(job.job_id, timeout=600)
return job.result.markdown
async def main() -> None:
async with AsyncNdiClient() as client:
pages = await asyncio.gather(
parse_one(client, "invoice.pdf"),
parse_one(client, "report.pdf"),
return_exceptions=True,
)
print([type(p).__name__ if isinstance(p, Exception) else len(p) for p in pages])
asyncio.run(main())