How to parse a document
Parse runs full-document OCR. It extracts all the text, keeps layout and reading order, and parses tables into HTML, Markdown, or JSON. Use it when you want the whole document as clean, structured content: archival, search, RAG ingestion, or reading-order-faithful conversion.
If you only need specific fields (an invoice total, a policy number), extract them instead of post-processing a full parse.
Quick start
API parameter names: Document AI uses language and output_format values "md", "html", or "json". Do not use language_code (it’s ignored) or "markdown" (it returns 400; use "md" instead). This differs from STT, translate, and LID endpoints.
JavaScript SDK: as of sarvamai 1.1.12, parse() does not send output_format, so JavaScript always returns HTML. Use the Python SDK or cURL for Markdown or JSON.
Download the output
When the job is completed or partially_completed, ask for the download link and save the ZIP. It holds your Markdown, HTML, or JSON file. See Read the output.
Full example (copy and run)
Submit, wait, and get the output in one script. Save it next to your document and run it.
Parameters
Output formats
The output_format parameter controls the primary content format. Choose html (the default), md (Markdown), or json.
Read the output
The ZIP you saved in the last step holds the primary file, a metadata/page_NNN.json per page, and a manifest.json:
The folder and file names follow your uploaded file name. The download link is a plain GET and needs no API key header. To read the Markdown file straight from the ZIP:
Match on .html or .json instead if you chose another output_format.
Limits
Page limit: PDF and ZIP uploads are limited to 30 pages for Parse. Exceeding the limit returns a 400 Bad Request with code invalid_request_error. Split larger documents into batches before uploading.
For ZIP files, include only JPG and PNG document pages in a flat structure (no nested folders). The API processes all pages in the archive and maintains page order based on filename.