Overview
GLM-OCR is a 0.9B MIT-licensed OCR model from Z.ai that pairs PP-DocLayout-V3 layout analysis with a GLM decoder.
OCRRouter calls it through OpenParser first, which returns layout blocks with pixel boxes. If that fails it falls back to AIHubMix, which returns text only, so the same job can come back with or without layout.
Price and limits
- Model ID
- zai/glm-ocr
- Price
- 6 credits / page ($6 per 1,000 pages)
- Max pages per request
- 500
- Inputs
- PDF; PNG, JPEG and other images
- Languages
- 100+ languages
- Positions (bbox)
- Yes, when the upstream returns them
- License
- MIT
- Up to 500 pages per job in OCRRouter
- OpenParser results carry no confidence for GLM-OCR
- AIHubMix backup returns no layout in OCRRouter output
- Model can be changed server-side with OPENPARSER_GLM_MODEL
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
- Gateway
- OpenParser
- Endpoint
- POST https://api.openparser.dev/parse (multipart)
- Upstream model
- ocr_model "glm-ocr"
- Request
- request part {"ocr_model", "output_format": "openparser@1"} plus the original file; Idempotency-Key header per call
- Long documents
- HTTP 202 with a job; OCRRouter polls /jobs/{id} with backoff from 1 to 5 seconds
- Backup
- AIHubMix chat completions, model "glm-ocr", prompt "Text Recognition:", same page rendering as other AIHubMix models
- Order
- OpenParser first, AIHubMix if it fails. GLM_OCR_UPSTREAM=aihubmix flips the order (server setting)
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
- "glm-ocr"
- output_format
- "openparser@1"
- File
- Sent as uploaded, no rendering
- Client options
- None. Callers cannot pass model options.
- Backup model / prompt
- "glm-ocr" / "Text Recognition:"
- Backup temperature
- 0
- Backup PDF render
- 150 dpi PNG, 4 pages at a time
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)
OpenParser runs GLM-OCR and converts its result into the openparser@1 document graph: pages with reading order, and elements with locations and scores. Field meanings follow the openparser@1 schema reference.
Source: openparser@1 schema, retrieved 2026-11-19
output_formatstring- Schema version, always "openparser@1".Example:
"openparser@1" document_idstring- Stable identifier for the parsed document.
provenance.provider / provenance.modelstring- Provider and model that produced the result.Example:
"baidu" / "paddleocr-vl-1.6" textstring, read by OCRRouter- Plain text in reading order. Spans index into it.
markdownstring, read by OCRRouter- Best-effort Markdown rendering of the whole document.
pages[].numberinteger, read by OCRRouter- One-based page number, contiguous 1 to N.Example:
1 pages[].width / heightnumber, read by OCRRouter- Size of the page coordinate space.Example:
800 / 300 pages[].unitstring, read by OCRRouter- Unit of the coordinate space: pixel, point, inch or normalized.Example:
"pixel" pages[].element_idsstring[], read by OCRRouter- IDs of elements on the page.
pages[].reading_orderstring[], read by OCRRouter- Ordered top-level element IDs for the page.
elements[].idstring, read by OCRRouter- Element ID, unique in the document.
elements[].kindstring, read by OCRRouter- Element type discriminator: text, table, figure, formula and others.Example:
"text" elements[].rolestring, read by OCRRouter- For text elements: heading, paragraph, line, word, page_header, page_footer and more.Example:
"heading" elements[].textstring, read by OCRRouter- Text of the element.Example:
"Total due: $42.50 by December 1." elements[].locations[].page_numberinteger, read by OCRRouter- Page the location is on.Example:
1 elements[].locations[].bboxobject, read by OCRRouter- Axis-aligned box {left, top, right, bottom} in page coordinates; right and bottom are exclusive.Example:
{"left":37,"top":107,"right":401,"bottom":135} elements[].locations[].polygonPoint[]- Tighter outline when the provider supplies one.
elements[].source.native_id / native_type / native_labelstring- The engine's own ID, type and label for the block. Not in the published schema page; present in responses.Example:
"1" / "layout_block" / "text" elements[].row_count / column_count / cells[]number / array, read by OCRRouter- For table elements: grid size and cells with row_index, column_index, text.
relations[], text_annotations[], assets[]array- Links between elements, span metadata, and page or figure images.Example:
[]
Real response captured 2026-11-19 from POST /parse on an 800x300 PNG with three lines of text. Trimmed to the first two elements; nothing else edited.
{"output_format": "openparser@1","document_id": "3fd622b1876c999f4f0c3e48a415c085","provenance": {"provider": "zai","model": "glm-ocr","operation": "layout_parsing"},"text": "Invoice 2026\n\nTotal due: $42.50 by December 1.\n…","markdown": "## Invoice 2026\n\nTotal due: $42.50 by December …","pages": [{"number": 1,"source_page_number": 1,"width": 800,"height": 300,"unit": "pixel","rotation_degrees": 0,"languages": [],"element_ids": ["3fd622b1876c999f4f0c3e48a415c085-glm-1-0","3fd622b1876c999f4f0c3e48a415c085-glm-1-1"],"reading_order": ["3fd622b1876c999f4f0c3e48a415c085-glm-1-0","3fd622b1876c999f4f0c3e48a415c085-glm-1-1"]}],"elements": [{"id": "3fd622b1876c999f4f0c3e48a415c085-glm-1-0","locations": [{"page_number": 1,"bbox": { "left": 38, "top": 27, "right": 246, "bottom": 63 }}],"source": {"native_id": "0","native_type": "layout_block","native_label": "paragraph_title"},"kind": "text","role": "heading","text": "Invoice 2026","spans": [],"languages": []},{"id": "3fd622b1876c999f4f0c3e48a415c085-glm-1-1","locations": [{"page_number": 1,"bbox": { "left": 37, "top": 106, "right": 401, "bottom": 135 }}],"source": {"native_id": "1","native_type": "layout_block","native_label": "text"},"kind": "text","role": "paragraph","text": "Total due: $42.50 by December 1.","spans": [],"languages": []}],"text_annotations": [],"relations": [],"assets": []}What OCRRouter receives from the backup (AIHubMix chat completion)
AIHubMix exposes glm-ocr through its OpenAI-compatible POST /v1/chat/completions endpoint. OCRRouter sends one request per page image and gets back a standard chat completion object. Field meanings follow OpenAI's chat completion object reference, which AIHubMix follows.
Source: OpenAI chat completion object, retrieved 2026-11-19
idstring- Unique identifier for the chat completion.Example:
"as-gkcbgipdih" objectstring- Object type, always "chat.completion".Example:
"chat.completion" createdinteger- Unix timestamp in seconds when the completion was created.Example:
1795104850 modelstring- Model that produced the completion.Example:
"deepseek-ocr" choices[]array, read by OCRRouter- List of completion choices. OCRRouter sends no n parameter, so there is one.
choices[].indexinteger- Position of the choice in the list.Example:
0 choices[].message.rolestring- Role of the message author, "assistant".Example:
"assistant" choices[].message.contentstring or null, read by OCRRouter- Text the model generated. For these OCR models this is the page transcription.Example:
"## Invoice 2026\n\nTotal due: ..." choices[].message.refusalstring or null- Refusal message if the model refused; null otherwise.Example:
null choices[].finish_reasonstring- Why generation stopped: "stop" for a natural end, "length" when the token limit was hit.Example:
"stop" choices[].logprobsobject or null- Log probabilities, only when requested. OCRRouter does not request them.Example:
null choices[].glm_ocr_detail.layout_details[][]array- Per-page layout blocks with bbox_2d, content, label, native_label, index, width, height. Not in AIHubMix docs. OCRRouter ignores it today.
choices[].glm_ocr_detail.data_infoobject- num_pages and per-page width and height.
usage.prompt_tokensinteger- Tokens in the prompt, including the image.Example:
593 usage.completion_tokensinteger- Tokens in the generated output.Example:
81 usage.total_tokensinteger- Prompt plus completion tokens. AIHubMix bills per token.Example:
674
Real response captured 2026-11-19 by OCRRouter with the exact request shown under Options, on an 800x300 PNG with three lines of text. Response id kept; nothing else edited.
{"id": "20261120001419f6803a31f3f44f78","object": "chat.completion","created": 1795104859,"model": "glm-ocr","choices": [{"index": 0,"message": {"role": "assistant","content": "## Invoice 2026\n\nTotal due: $42.50 by December …"},"finish_reason": "stop","glm_ocr_detail": {"layout_details": [[{"bbox_2d": [38, 28, 247, 64],"content": "## Invoice 2026","height": 300,"index": 0,"label": "text","native_label": "paragraph_title","width": 800},{"bbox_2d": [37, 107, 401, 135],"content": "Total due: $42.50 by December 1.","height": 300,"index": 1,"label": "text","native_label": "text","width": 800},{"bbox_2d": [37, 158, 347, 187],"content": "Thank you for your business.","height": 300,"index": 2,"label": "text","native_label": "text","width": 800}]],"layout_visualization": [],"data_info": {"num_pages": 1,"pages": [{ "height": 300, "width": 800 }]}}}],"usage": {"prompt_tokens": 118,"completion_tokens": 30,"total_tokens": 148}}GLM-OCR native output (Z.ai layout_parsing API)
What Z.ai's own POST /paas/v4/layout_parsing returns. OpenParser maps layout_details into elements. Note the docs say bbox_2d is normalized 0 to 1, but the AIHubMix response above carries pixel values.
Source: Z.ai layout parsing API, retrieved 2026-11-19
idstring- Task ID.
createdinteger- Creation time, Unix seconds.
modelstring- Model that handled the request.
md_resultsstring- Recognized content as Markdown.
layout_details[][]array of arrays- Layout blocks, one inner array per page.
layout_details[][].indexinteger- Element index.
layout_details[][].labelstring- Element type: image, text, formula or table.
layout_details[][].bbox_2dnumber[4]- Element box [x1, y1, x2, y2], documented as normalized 0 to 1.
layout_details[][].contentstring- Text, image URL or table HTML depending on label.
layout_details[][].width / heightinteger- Page width and height.
layout_visualizationstring[]- URLs of result images.
data_info.num_pagesinteger- Total pages.
data_info.pages[]array- Width and height per page.
usage.prompt_tokens / completion_tokens / total_tokensinteger- Token counts.
usage.prompt_tokens_details.cached_tokensinteger- Tokens served from cache.
request_idstring- Request ID.
Built from the example values in Z.ai's API reference, not a captured response.
{"id": "task_123456789","created": 1727156815,"model": "GLM-OCR","md_results": "# Doc title\nThis is the document content...","layout_details": [[{"index": 1,"label": "text","bbox_2d": [0.1, 0.1, 0.5, 0.3],"content": "This is the content of the element","width": 600,"height": 800}]],"layout_visualization": ["https://example.com/visualization/page1.png"],"data_info": {"num_pages": 5,"pages": [{ "width": 600, "height": 800 }]},"usage": {"prompt_tokens": 1024,"completion_tokens": 512,"prompt_tokens_details": { "cached_tokens": 0 },"total_tokens": 1536},"request_id": "req_123456789"}How it maps to OCRRouter output
- pages[] sorted by number
- One OCRRouter page each
- pages[].reading_order (else element_ids)
- Order of layout blocks and Markdown on the page
- elements[].kind + role
- Block type: table, formula, figure/image/picture -> image, heading/title -> heading, else paragraph
- elements[].text (or markdown)
- Block text. Headings are normalized to one run of #, level 1 to 6
- Table cells
- Rebuilt as a GitHub-flavoured Markdown table; first row is the header
- locations[].bbox
- Block bbox [left, top, right, bottom], using the location on the same page
- pages[].width, height, unit
- Page layout width, height and unit (pixel here)
- confidence.score
- Block confidence (0 to 1); null when absent
- Page Markdown
- Block texts joined with blank lines
- Document markdown
- Fallback only when no element has text: all of it goes on page 1
- Backup: choices[0].message.content
- Page text, HTML tables rewritten as Markdown; no layout, bbox or confidence
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": "zai/glm-ocr",
"file_url": "https://example.com/invoice.pdf",
"format": "json"
}'Sources
Vendor documentation read on 2026-11-19.