Option 1: use Xiaomi-OCR-0 online
The quickest way is the online demo on the OCRZero homepage. Nothing to install, and the output is the same Markdown or JSON the API returns.
- Choose a task. Page OCR to Markdown, PDF batch, invoice or form fields to JSON, or document Q&A.
- Upload the document. A PNG, JPEG or WebP image up to 10 MB, or a PDF of up to 20 pages.
- Copy the result. Markdown with HTML tables and LaTeX formulas, a JSON object, or a short answer.
Option 2: call the Xiaomi-OCR-0 API
Create an API key in your OCRZero account and send the file as a base64 data URL to POST /api/v1/ocr with a mode: page, pdf, kie or vqa. Each page uses 1 credit, and failed pages are refunded in the same response.
For invoices and forms, send mode kie with the field names you want, for example invoice_number, invoice_date and total_amount. Fields the model cannot find come back as empty strings.
Option 3: self-host the model
The weights are on Hugging Face. The official instructions serve them with vLLM or SGLang as an OpenAI-compatible server with a 16,384-token context, then send the image together with a fixed prompt. Use the official prompts unchanged: the model was trained on them.
- Page prompt: extract the main body as Markdown, tables in OTSL, formulas in LaTeX, in reading order.
- Decoding: temperature 0, top_p 0.8, thinking disabled.
- Postprocess: convert OTSL tables to HTML and normalise math delimiters with the official postprocess code.