GLM-OCR

GLM_OCR

GLM-OCR reads documents in pictures: it writes out the text of a page, tables as HTML and formulas as LaTeX, and can pull named fields such as an invoice number or a total out of a page as JSON.

Vision & Analysisocrdocument-parsingtablesformulasinformation-extractionmultilingualglmmitFine-tunable
GLM-OCR: Vision & Analysis model on Kainguru

About GLM-OCR

Capabilities

  • Pages to text — printed and handwritten text, in reading order, with the structure of the page kept
  • Tables and formulas — tables as HTML, formulas as LaTeX
  • Fields as JSON — name the fields to find (an invoice number, a date, a total) and get them back as JSON
  • Fine-tuning — teach it your own documents with pictures and the text they should read as

Good to know

  • Pictures are JPEG, PNG or WebP, at most 20 MB and 40 megapixels each, at least 16 pixels a side and at most 20 times wider than tall; larger pictures are scaled down to about 2 megapixels first.
  • One picture a request, read as the task says: text (the default), table, formula, or extract with a schema, a JSON object whose keys are the fields to find (at most 4,096 characters, 100 fields, 4 levels deep); the model fills them in. The prompts are the model's own: the request never sends free text.
  • The text is at most 4,096 tokens (max_new_tokens, 2,048 by default) and the picture and prompt together at most 6,144 tokens; the picture's tokens are billed as input tokens. A dense page is 1,000 to 3,000 tokens.
  • The model reads a whole picture at once: it does best on a page, a column or a block of text. Chinese, English, French, Spanish, Russian, German, Japanese and Korean are its listed languages; check others with a sample.
  • Fine-tuning data is a JSONL manifest plus the pictures it names, or one ZIP holding both: 4 to 5,000 lines, each {"file": ..., "text": ...} with an optional "task" (and, for extract, the "schema") and the text the model should write, at most 32,768 characters.
  • Uploaded one by one, the dataset is at most 1000 files and 4 GB in all, the manifests at most 64 MB, and each "file" is the URL or name the picture's upload returned (such as 0192f3c4-7e1a-7c2b-9d5e-1f2a3b4c5d6e.png), never the name it had on your computer.
  • As a ZIP, it is at most 4 GB and 10,000 entries without a password and holds exactly one .jsonl (or .ndjson) manifest; picture paths are relative to that manifest.
  • An example's picture, prompt and text are at most max_seq_len tokens: a longer text is cut, and at most 2,048 text tokens are learned. If a picture and its prompt alone are longer, the whole fine-tune is refused, naming that line; raise max_seq_len or use a smaller picture.
  • Training stops after 9 hours or 5,000 steps of 8 examples, whichever comes first, and keeps what it learned.

GLM-OCR inputs and output

NameTypeRequiredDefaultDetails
imagefileYes—A page or a part of one: JPEG, PNG or WebP, at most 20 MB and 40 megapixels.
Max 2048 characters · image/jpeg, png, webp
schematextNo—For task extract: a JSON object of the fields to find, such as {"invoice_number": "", "total": ""}; nested objects are allowed.
Max 4096 characters
max_new_tokensintegerNo2048The most tokens the text may have; a dense page is 1,000 to 3,000.
1–4096
tasktextNotextWhat to read the picture as: text, formula, table, extract. The default, text, is the plain text.
Allowed: text, formula, table, extract

Output. The text of the picture as the model writes it: plain text, tables as HTML, formulas as LaTeX, or for extract the JSON of the fields asked for.

Run GLM-OCR with the API

Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.

cURL
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=GLM_OCR" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "image": "https://example.com/input.png",
    "max_new_tokens": 2048,
    "task": "text"
  },
  "outputFormat": "json"
}'

# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
  -H "X-API-Key: kg_your_api_key"
Python
from kainguru import KainguruClient

with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
    submitted = client.executions.execute(
        "GLM_OCR",
        {
          "image": "https://example.com/input.png",
          "max_new_tokens": 2048,
          "task": "text"
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune GLM-OCR

You can fine-tune GLM-OCR on your own data and run the tuned model through the same API. Dataset: A JSONL manifest plus its pictures, or one ZIP with both: one {"file", "text", "task", "schema"} per line, 4 to 5,000 lines, 4 GB in all. More rules: Good to know, in the README.

The steps are in the docs.

GLM-OCR pricing

Price per 1M tokens: 1748 credits ($17.48). The price is shown again before every run; all prices are on the pricing page.

Licence and source

PaddleOCR-VL 1.6: Vision & Analysis model on Kainguru
Vision & Analysis

PaddleOCR-VL 1.6

PaddleOCR-VL 1.6 reads documents in pictures in many languages: it writes out the text of a page, its tables…

Fine-tunable
Florence-2 Large: Vision & Analysis model on Kainguru
Vision & Analysis

Florence-2 Large

One small vision model that captions images, reads text, boxes objects and finds things named by a phrase.

Fine-tunable
EasyOCR: Vision & Analysis model on Kainguru
Vision & Analysis

EasyOCR

EasyOCR finds the lines of text in a photo or a scan and reads each one, returning every line with its box and its…

Fine-tunable
Qwen3-VL 8B Instruct: Vision & Analysis model on Kainguru
Vision & Analysis

Qwen3-VL 8B Instruct

Qwen3-VL 8B Instruct answers questions about up to four pictures: it describes photos, reads printed and handwritten…

Fine-tunable
BLIP2 Flan T5 XL: Vision & Analysis model on Kainguru
Vision & Analysis

BLIP2 Flan T5 XL

Describes a photo in a sentence or answers a question about it in plain English.

Fine-tunable
Granite Vision 3.3 2B: Vision & Analysis model on Kainguru
Vision & Analysis

Granite Vision 3.3 2B

IBM Granite Vision 3.3 2B reads documents in pictures: it answers questions about tables, charts, infographics, forms…

Fine-tunable