OCRRouter

Google Document AI API docs

How OCRRouter calls Google Document AI, what the upstream returns field by field, and how that becomes Markdown and JSON blocks.

Overview

Google Document AI Enterprise Document OCR processor, reached through OpenParser. It returns blocks, paragraphs, lines and tokens with confidence, detected languages and image quality scores.

OCRRouter turns OpenParser's openparser@1 output into per-page Markdown plus layout blocks. The OCR processor does not label headings or tables, so blocks mostly arrive as paragraphs.

Price and limits

Model ID
google/document-ai
Price
10 credits / page ($10 per 1,000 pages)
Max pages per request
500
Inputs
PDF; Images
Languages
200+ languages
Positions (bbox)
Yes, when the upstream returns them
  • OCRRouter catalog limit: 500 pages

You pay only for pages that succeed. A failed attempt that falls back to another model is not charged. See pricing.

How OCRRouter calls it

Endpoint
POST https://api.openparser.dev/parse (multipart: request JSON + file)
Upstream model
OpenParser ocr_model "google-docai-ocr" (Document AI OCR_PROCESSOR)
Auth
Bearer OpenParser API key, server side
Long jobs
HTTP 202, then poll the job until it succeeds

Options

What OCRRouter sets on the upstream call. You choose the model, format and pages in your request; vendor-specific options are not passed through.

ocr_model
"google-docai-ocr" (in the JSON request part)
output_format
"openparser@1"
Idempotency-Key
A fresh UUID per request, required by OpenParser
Client options
None. Clients cannot pass vendor options such as page ranges, features or output format.

Raw response fields

Every field the upstream documents, with its type and meaning taken from the vendor's own reference. Fields marked "read by OCRRouter" are the ones our connector uses; the rest are listed so you know what the engine produces.

What OCRRouter receives: OpenParser openparser@1

OCRRouter never calls Google Document AI directly. OpenParser runs the vendor call and converts the vendor response to its own openparser@1 document, which is the only shape OCRRouter sees. Fields marked used are the ones OCRRouter reads.

Source: OpenParser openparser@1 schema, retrieved 2026-11-19

output_format"openparser@1"
Schema version identifier.Example: "openparser@1"
document_idstring
Stable identifier for the parsed document.
provenanceobject
Provider and model metadata: provider, model, version, operation.Example: {"provider":"google","model":"OCR_PROCESSOR","version":"pretrained-ocr-v2.1-2024-08-07"}
textstring, read by OCRRouter
Plain text of the whole document in reading order. Spans index into it.
markdownstring, read by OCRRouter
Best-effort Markdown rendering of the whole document. Used as the fallback when elements carry no text.Example: "# Invoice 1042\n\nItem Qty"
pages[]DocumentPage[], read by OCRRouter
Coordinate space and reading order of each page.
pages[].numbernumber, read by OCRRouter
One-based page number. Numbers are contiguous.Example: 1
pages[].widthnumber, read by OCRRouter
Page width in the page's coordinate unit.
pages[].heightnumber, read by OCRRouter
Page height in the page's coordinate unit.
pages[].unit"pixel" | "point" | "inch" | "normalized", read by OCRRouter
Coordinate unit for every bbox on the page.Example: "pixel"
pages[].element_idsstring[], read by OCRRouter
IDs of all elements on the page, including lines and words.
pages[].reading_orderstring[], read by OCRRouter
Ordered subset of element_ids, limited to top-level content.
pages[].confidenceConfidence
Optional page-level OCR aggregate.
pages[].qualityPageQuality
Optional image-quality scores, defects and metrics, separate from confidence.
elements[]DocumentElement[], read by OCRRouter
Text, tables, figures and other semantic content.
elements[].idstring, read by OCRRouter
Element ID, referenced from pages[].reading_order.
elements[].kindstring, read by OCRRouter
One of text, table, figure, formula, key_value, query_answer, section, selection_mark, signature, barcode, link, stamp, other.Example: "text"
elements[].rolestring, read by OCRRouter
For text elements: heading, paragraph, line, word, page_header, page_footer and similar.
elements[].textstring, read by OCRRouter
Element text.
elements[].markdownstring, read by OCRRouter
Element text as Markdown, when provided. Read before text.
elements[].spans[]{start,end}[]
UTF-16 offsets into the document text, end exclusive.
elements[].locations[].page_numbernumber, read by OCRRouter
Page the location is on.Example: 1
elements[].locations[].bbox{left,top,right,bottom}, read by OCRRouter
Axis-aligned box in page-local coordinates; right and bottom are exclusive.
elements[].locations[].polygon{x,y}[]
Tighter outline when the source provides one.
elements[].confidence.scorenumber, read by OCRRouter
Score normalised to 0 to 1.
elements[].confidence.scopestring
What the score measures: detection, recognition, classification, geometry, answer or quality.
elements[].confidence.calibratedboolean
Defaults to false. Uncalibrated scores should not be compared across providers or scopes.
elements[].confidence.source_valuenumber
The provider's original score.
elements[].confidence.source_scalestring
Scale of the original score: zero_to_one, zero_to_hundred, log_probability or unknown.
elements[].row_countnumber, read by OCRRouter
Table rows.
elements[].column_countnumber, read by OCRRouter
Table columns.
elements[].cells[].row_indexnumber, read by OCRRouter
Cell row position.
elements[].cells[].column_indexnumber, read by OCRRouter
Cell column position.
elements[].cells[].row_spannumber
Rows the cell covers.
elements[].cells[].column_spannumber
Columns the cell covers.
elements[].cells[].textstring, read by OCRRouter
Cell text.
relations[]DocumentRelation[]
Directed links between elements, such as containment and captions.Example: {"type":"contains","from_id":"...","to_id":"..."}
text_annotations[]TextAnnotation[]
Language and style metadata over spans of text.
assets[]DocumentAsset[]
Page and figure images.

Real response captured 2026-11-19 from POST /parse on a small 600 x 260 PNG. Trimmed to the first two reading-order elements, one relation, and the first element IDs.

{"output_format": "openparser@1","document_id": "b1c4a829aacf83ef0491f8b0f0a48e5c","provenance": {"provider": "google","model": "OCR_PROCESSOR","version": "pretrained-ocr-v2.1-2024-08-07","operation": "ocr_processor"},"text": "Invoice 1042\nItem Qty\nPaper 2\n","markdown": "Invoice 1042\n\n\nItem Qty\nPaper 2\n","pages": [{"number": 1,"source_page_number": 1,"width": 600,"height": 260,"unit": "pixel","rotation_degrees": 0,"languages": [{"code": "en","confidence": {"score": 1,"scope": "classification","calibrated": false,"source_value": 1,"source_scale": "zero_to_one"}}],"quality": {"score": {"score": 0.96369535,"scope": "quality","calibrated": false,"source_value": 0.96369535,"source_scale": "zero_to_one"},"defects": [{"type": "quality/defect_document_cutoff","confidence": {"score": 1,"scope": "quality","calibrated": false,"source_value": 1,"source_scale": "zero_to_one"}},{"type": "quality/defect_glare","confidence": {"score": 0.7330233,"scope": "quality","calibrated": false,"source_value": 0.7330233,"source_scale": "zero_to_one"}},{"type": "quality/defect_text_cutoff","confidence": {"score": 0.5,"scope": "quality","calibrated": false,"source_value": 0.5,"source_scale": "zero_to_one"}}],"metrics": []},"element_ids": ["google-page-1-blocks-0","google-page-1-blocks-1","google-page-1-paragraphs-0","google-page-1-paragraphs-1","..."],"reading_order": ["google-page-1-blocks-0", "google-page-1-blocks-1"]}],"elements": [{"id": "google-page-1-blocks-0","locations": [{"page_number": 1,"bbox": { "left": 30, "top": 21, "right": 191, "bottom": 43 },"polygon": [{ "x": 30, "y": 21 },{ "x": 191, "y": 21 },{ "x": 191, "y": 43 },{ "x": 30, "y": 43 }],"rotation_degrees": 0}],"confidence": {"score": 0.986845,"scope": "recognition","calibrated": false,"source_value": 0.986845,"source_scale": "zero_to_one"},"source": { "native_id": "1:blocks:0", "native_type": "block" },"kind": "text","role": "paragraph","text": "Invoice 1042\n","spans": [{ "start": 0, "end": 13 }],"languages": []},{"id": "google-page-1-blocks-1","locations": [{"page_number": 1,"bbox": { "left": 27, "top": 72, "right": 179, "bottom": 136 },"polygon": [{ "x": 27, "y": 72 },{ "x": 179, "y": 72 },{ "x": 179, "y": 136 },{ "x": 27, "y": 136 }],"rotation_degrees": 0}],"confidence": {"score": 0.98631376,"scope": "recognition","calibrated": false,"source_value": 0.98631376,"source_scale": "zero_to_one"},"source": { "native_id": "1:blocks:1", "native_type": "block" },"kind": "text","role": "paragraph","text": "Item Qty\nPaper 2\n","spans": [{ "start": 13, "end": 30 }],"languages": []}],"text_annotations": [],"relations": [{"type": "contains","from_id": "google-page-1-blocks-0","to_id": "google-page-1-paragraphs-0"}],"assets": []}

The vendor's own response: Document AI Document

What Document AI returns to OpenParser. OCRRouter never sees this JSON; it is shown so you know where the openparser@1 values come from (page blocks become paragraph elements, imageQualityScores become pages[].quality).

Source: Document AI Document REST reference, retrieved 2026-11-19

uristring
Cloud Storage URI of the source file, when not sent inline.
contentbytes (base64)
Inline source file bytes.
mimeTypestring
IANA media type of the document.Example: "application/pdf"
textstring
Full UTF-8 text of the document in reading order.
pages[].pageNumberinteger
1-based page index.Example: 1
pages[].dimension{width,height,unit}
Physical page size.Example: {"width":1700,"height":2200,"unit":"pixels"}
pages[].imageImage
Rendered page image after preprocessing.
pages[].layoutLayout
Layout for the whole page.
pages[].layout.textAnchor.textSegments[]{startIndex,endIndex}[]
Ranges of Document.text the layout covers; end exclusive.
pages[].layout.confidencenumber
Confidence of the layout, 0 to 1.
pages[].layout.boundingPoly.vertices[]{x,y}[]
Polygon in pixel coordinates.
pages[].layout.boundingPoly.normalizedVertices[]{x,y}[]
Polygon scaled 0 to 1.
pages[].layout.orientationenum
PAGE_UP, PAGE_RIGHT, PAGE_DOWN or PAGE_LEFT.
pages[].detectedLanguages[]{languageCode,confidence}[]
BCP-47 language code with confidence 0 to 1.Example: {"languageCode":"en","confidence":0.98}
pages[].blocks[]Block[]
Text blocks, each with a layout.
pages[].paragraphs[]Paragraph[]
Paragraphs, each with a layout.
pages[].lines[]Line[]
Lines, each with a layout.
pages[].tokens[]Token[]
Words with layout, detectedBreak, detectedLanguages and styleInfo.
pages[].visualElements[]VisualElement[]
Non-text elements such as check boxes or signatures.
pages[].tables[]Table[]
Tables with layout, headerRows[] and bodyRows[] of cells (layout, rowSpan, colSpan).
pages[].formFields[]FormField[]
Form key-value fields.
pages[].symbols[]Symbol[]
Character-level symbols, when requested.
pages[].detectedBarcodes[]DetectedBarcode[]
Barcodes found on the page.
pages[].imageQualityScoresImageQualityScores
Image quality score and detected defects.
pages[].transforms[]Matrix[]
Transforms applied to produce the page image.
entities[]Entity[]
Entities detected by the processor.
textChanges[]TextChange[]
Corrections applied to the text.
shardInfo{shardIndex,shardCount,textOffset,pageOffset}
Position of this shard when the output is split.
errorStatus
Processing error, if any.
documentLayoutDocumentLayout
Parsed layout blocks (Layout Parser).
chunkedDocumentChunkedDocument
Chunks built from the chunking config (Layout Parser).

Built from the field structure in Google's Document reference, which has no example response. Values mirror the real OpenParser capture on the same test image.

{"mimeType": "image/png","text": "Invoice 1042\nItem Qty\n","pages": [{"pageNumber": 1,"dimension": { "width": 600, "height": 260, "unit": "pixels" },"layout": {"textAnchor": {"textSegments": [{ "endIndex": "22" }]},"confidence": 0.98,"boundingPoly": {"vertices": [{ "x": 0, "y": 0 },{ "x": 600, "y": 0 },{ "x": 600, "y": 260 },{ "x": 0, "y": 260 }]},"orientation": "PAGE_UP"},"detectedLanguages": [{ "languageCode": "en", "confidence": 0.98 }],"blocks": [{"layout": {"textAnchor": {"textSegments": [{ "endIndex": "13" }]},"confidence": 0.98,"boundingPoly": {"vertices": [{ "x": 30, "y": 21 },{ "x": 191, "y": 21 },{ "x": 191, "y": 43 },{ "x": 30, "y": 43 }]},"orientation": "PAGE_UP"}}],"tokens": [{"layout": {"textAnchor": {"textSegments": [{ "endIndex": "8" }]},"confidence": 0.99},"detectedBreak": { "type": "SPACE" }}]}]}

How it maps to OCRRouter output

pages[] sorted by number
One Markdown string and one layout page per page
pages[].reading_order (else element_ids)
Block order on the page
elements[].kind + role containing table
table block
kind/role containing formula or equation
formula block
kind/role containing figure, image or picture
image block
kind/role containing heading or title
heading block, text prefixed with # (level 1 to 6)
anything else
paragraph block
elements[].markdown, else text
Block text
cells[] with row_count/column_count
GitHub Markdown table, first row as header
locations[].bbox on that page
bbox [left, top, right, bottom] in pages[].unit
pages[].width/height/unit
Layout page size and unit
confidence.score
Block confidence 0 to 1, or null
No element text on any page
Document markdown (else text) returned as page 1, no layout
HTTP 202 with job
Poll GET /jobs/{id} (or Location) with backoff 1 to 5 s until succeeded or failed
Document AI page blocks
OpenParser text elements with role paragraph, then OCRRouter paragraph blocks
imageQualityScores
OpenParser pages[].quality, not read by OCRRouter

The unified output is described in Response format.

Example request

curl https://api.ocrrouter.ai/v1/ocr \
  -H "Authorization: Bearer $OCRROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/document-ai",
    "file_url": "https://example.com/invoice.pdf",
    "format": "json"
  }'

Sources

Vendor documentation read on 2026-11-19.