Document OCR API
Document OCR models read PDFs and images and return every page as Markdown: text in reading order, headings, lists, tables, math, headers and footers, and the position of every image on the page. Send a document as a URL or a base64 data URI, choose the pages, and each page comes back as its own object.
Endpoint
Authenticate with your API key in the Authorization header:
The full request and response schema is in the API reference.
Models
Your first request
This request reads the first two pages of a PDF.
An image works the same way with "type": "image_url":
Send a local file
Either URL can be a base64 data URI, so a file on your machine needs no hosting:
A document can be up to 50 MB. A URL must be publicly reachable over HTTPS or HTTP.
The response
Choose pages
pages takes zero-based page numbers as a list ([0, 2, 3]) or a string ("0,2-4"). Leave it out to read every page. A request reads at most 1,000 pages; for a longer document, send it in parts with pages.
Images, tables, headers, and footers
Image and table ids run across the whole document: the second page continues where the first stopped.
Long documents
A request answers when its pages are read. A request still running after about four and a half minutes answers 202 with a job_id instead; poll GET /v1/jobs/{job_id} until status is completed, and the response is in result. To get the job id at once, send the header Prefer: respond-async.
Billing
Billed per page read, at the price on the model page, with the minimum per request shown there. A request that fails is not billed for pages it did not return.
Errors
bbox_annotation_format, document_annotation_format, and document_annotation_prompt are not supported, and a request that sends them answers 400 before any page is read.
