Quickstart Code Example
Submit a document, poll for completion, and read the text — in Python
The OCR API takes a file as a raw request body and returns layout-aware text. This page builds up a working client in four steps; the complete script is at the end.
You need an API key. Set it in your environment rather than putting it in code:
Create a session
Authentication is an API key sent as a bearer token. Putting it on a
requests.Session means every call below carries it.
Submit a document
Post the file as the raw request body — not multipart, and not a JSON wrapper.
The format is detected from the file’s own bytes, so the Content-Type header is
ignored; PDF, PNG, JPEG and TIFF are accepted. X-Filename sets the job’s
display name and is optional.
Wait for it to finish
A job moves through queued → rendering → ocr → done, or ends in
failed. Poll the status endpoint until it reaches a terminal state.
Add ?timings=true to the status call to get per-page render and OCR
durations, which is the quickest way to see where time goes on a large
document.
Read the result
Results auto-purge after retrieval or a short retention window, so read them once and store what you need. To release the input file and rendered pages immediately:
