Agent skill

Glmocr SDK

by zai-org in zai-org/GLM-skills

Trigger when: (1) User wants to extract text, tables, formulas, or structured data from images/PDFs/scanned documents, (2) User mentions "OCR", "文字识别", "文档解析", (3) User has a document (screenshot…

Apache-2.0Auto-check: notesDocuments & Office

Install Glmocr SDK

skills CLI
$ npx skills add zai-org/GLM-skills --skill glmocr-sdk -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install zai-org/GLM-skills glmocr-sdk --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/zai-org/GLM-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/glmocr-sdk .claude/skills/glmocr-sdk && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
glmocr-sdk
GitHub stars
475
Token cost
~2.7k tokens
SKILL.md length
405 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
Apache-2.0

At a glance

Trigger when: (1) User wants to extract text, tables, formulas, or structured data from images/PDFs/scanned documents, (2) User mentions "OCR", "文字识别", "文档解析", (3) User has a document (screenshot…

  • User wants to extract text
  • SKILL.md covers ⚡ Quick Start, Configuration Priority, Python API and Working with PipelineResult, plus 4 more sections
  • Calls pip and jq; needs ZHIPU_API_KEY
  • Structured data from images/PDFs/scanned documents

What it does

Glmocr SDK is an agent skill from zai-org/GLM-skills. Trigger when: (1) User wants to extract text, tables, formulas, or structured data from images/PDFs/scanned documents, (2) User mentions "OCR", "文字识别", "文档解析", (3) User has a document (screenshot, scanned page, invoice, paper, whiteboard photo) and needs its content in structured form, (4) User asks to parse, digitize, or extract content from a visual document. Invokes the GLM-OCR SDK (pip install glmocr) to parse documents via Zhipu's cloud API. No GPU required. Returns structured JSON (regions with labels +…

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Documents & Office, covering PDF, Forms and invoices and Schema markup. It works with Zhipu GLM. The repository describes itself as: Official skills for the GLM family of models. The licence is Apache-2.0.

When your agent uses it

  • User wants to extract text
  • Structured data from images/PDFs/scanned documents
  • User mentions OCR
  • User has a document (screenshot

Example prompts

  • “/glmocr-sdk”

Requirements

  • Python 3
  • A credential in ZHIPU_API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 2ecd31c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip
    • jq

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • ZHIPU_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Glmocr SDK loads about 2.7k tokens when it runs. Until then it costs about 180 tokens; SKILL.md has 405 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~180
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:33
    # or add to .env file in working directory:
  • NoteMentions a .env fileSKILL.md:34
    echo "ZHIPU_API_KEY=sk-xxx" >> .env
  • NoteMentions a .env fileSKILL.md:49
    # Or load from a specific .env file
  • NoteMentions a .env fileSKILL.md:50
    mocr parse image.png --env-file /path/to/.env
  • NoteMentions a .env fileSKILL.md:52
    # Or rely on env var / auto-discovered .env (set once, then omit)
  • NoteMentions a .env fileSKILL.md:62
    Constructor kwargs  >  os.environ  >  .env file  >  config.yaml  >  built-in defaults
  • NoteMentions a .env fileSKILL.md:265
    --env-file`      | auto       | Path to `.env` file (default: auto-discover from cwd) |
  • NoteMentions a .env fileSKILL.md:346
    `export ZHIPU_API_KEY=sk-xxx`, add to a `.env` file, or pass `--api-key sk-xxx` to the CLI.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from zai-org/GLM-skills at commit 2ecd31c, republished under its Apache-2.0 licence (© zai-org). 405 words, ~2,683 tokens.

Download SKILL.mdSave it as .claude/skills/glmocr-sdk/SKILL.md (or your agent's skills folder).
name
glmocr-sdk
description
Trigger when: (1) User wants to extract text, tables, formulas, or structured data from images/PDFs/scanned documents, (2) User mentions "OCR", "文字识别", "文档解析", (3) User has a document (screenshot, scanned page, invoice, paper, whiteboard photo) and needs its content in structured form, (4) User asks to parse, digitize, or extract content from a visual document. Invokes the GLM-OCR SDK (pip install glmocr) to parse documents via Zhipu's cloud API. No GPU required. Returns structured JSON (regions with labels + bounding boxes) and Markdown. Agent can operate entirely via CLI — no YAML files needed. NOT for: real-time camera feeds, audio transcription, or non-document images (photos, illustrations).

OpenClaw Skill: glmocr

Parses documents (images, PDFs, scans) via the GLM-OCR SDK.

📌 On-demand: This skill requires only ZHIPU_API_KEY in the environment. No YAML config files or GPU needed.

⚡ Quick Start

bash
# Install
pip install glmocr

# Set API key (once)
export ZHIPU_API_KEY=sk-xxx
# or add to .env file in working directory:
echo "ZHIPU_API_KEY=sk-xxx" >> .env
python
# One-liner
import glmocr
result = glmocr.parse("document.pdf")
print(result.markdown_result)
print(result.to_dict())
bash
# CLI — pass API key directly (no env setup needed)
glmocr parse image.png --api-key sk-xxx

# Or load from a specific .env file
glmocr parse image.png --env-file /path/to/.env

# Or rely on env var / auto-discovered .env (set once, then omit)
glmocr parse image.png
glmocr parse ./scans/ --output ./output/ --stdout

Configuration Priority

Constructor kwargs  >  os.environ  >  .env file  >  config.yaml  >  built-in defaults

Agents override everything via constructor kwargs or env vars — no YAML editing needed.

Key Environment Variables
VariableDescriptionExample
ZHIPU_API_KEYAPI key (required for MaaS)sk-abc123
GLMOCR_MODELModel nameglm-ocr
GLMOCR_TIMEOUTRequest timeout (seconds)600
GLMOCR_ENABLE_LAYOUTLayout detection on/offtrue
GLMOCR_LOG_LEVELDEBUG / INFO / WARNING / ERRORINFO

Python API

Convenience function (single call)
python
import glmocr

# Single file → PipelineResult
result = glmocr.parse("invoice.png")

# Multiple files → list[PipelineResult]
results = glmocr.parse(["page1.png", "page2.png", "report.pdf"])
Class-based (multiple calls / resource reuse)
python
from glmocr import GlmOcr

parser = GlmOcr(api_key="sk-xxx")   # mode auto-set to "maas"
parser = GlmOcr(mode="maas")        # reads ZHIPU_API_KEY from env

# Always use as context manager or call .close()
with GlmOcr(api_key="sk-xxx") as parser:
    result = parser.parse("document.png")
    print(result.markdown_result)

parser.close()   # if not using `with`
Constructor Parameters
ParameterTypeDescription
api_keystrAPI key. Providing this auto-enables MaaS mode.
api_urlstrOverride MaaS endpoint URL
modelstrModel name override
timeoutintRequest timeout in seconds (default: 600)
enable_layoutboolEnable layout detection
log_levelstrLogging level

Working with PipelineResult

Fields
python
result.markdown_result    # str — full document as Markdown
result.json_result        # list[list[dict]] — structured regions per page
result.original_images    # list[str] — absolute paths of input images
json_result structure

List of pages → list of regions per page:

json
[
  [
    {
      "index": 0,
      "label": "title",
      "content": "Annual Report 2024",
      "bbox_2d": [100, 50, 900, 120]
    },
    {
      "index": 1,
      "label": "table",
      "content": "| Q1 | Q2 |\n|---|---|\n| 120 | 145 |",
      "bbox_2d": [100, 140, 900, 400]
    }
  ]
]

Bounding boxes (bbox_2d): [x1, y1, x2, y2] normalised to 0–1000 scale.

Region labels: title, text, table, figure, formula, header, footer, page_number, reference, seal

Serialization
python
# Dict (JSON-serializable, for passing to other tools)
d = result.to_dict()
# Keys: json_result, markdown_result, original_images, usage (MaaS), data_info (MaaS)

# JSON string
json_str = result.to_json()                 # pretty-printed, ensure_ascii=False
json_str = result.to_json(indent=None)      # compact single line

# Save to disk: writes <stem>/<stem>.json + <stem>/<stem>.md + layout_vis/
result.save(output_dir="./output")
result.save(output_dir="./output", save_layout_visualization=False)
Error Handling

The SDK does not raise on MaaS errors — check to_dict() for an "error" key:

python
result = parser.parse("image.png")
d = result.to_dict()
if "error" in d:
    # Handle failure
    print("OCR failed:", d["error"])
else:
    print(d["markdown_result"])

CLI Reference

Agent-preferred interface: use the CLI for most operations. Set ZHIPU_API_KEY in env once, then invoke as needed.

Supported input formats: .jpg, .jpeg, .png, .bmp, .gif, .webp, .pdf

Basic usage
bash
# Parse a single file → saves to ./output/<stem>/
# MaaS mode is the default; ZHIPU_API_KEY must be set (or use --api-key)
glmocr parse image.png

# Pass API key directly without any env setup
glmocr parse image.png --api-key sk-xxx

# Parse a directory → saves each file to ./output/<stem>/
glmocr parse ./scans/

# Use self-hosted vLLM/SGLang instead of cloud
glmocr parse image.png --mode selfhosted

# Specify output directory
glmocr parse image.png --output ./results/
Read results in the terminal (agent-friendly)
bash
# Print Markdown + JSON to stdout (and still save to disk)
glmocr parse image.png --stdout

# Print to stdout ONLY — do not write any files
glmocr parse image.png --stdout --no-save

# JSON only (no Markdown output)
glmocr parse image.png --stdout --json-only

# Pipe JSON into jq for structured extraction
glmocr parse image.png --stdout --json-only --no-save | jq '.[0] | map(select(.label=="table"))'
Save control
bash
# Skip layout visualization images (faster, smaller output)
glmocr parse image.png --no-layout-vis

# Parse and save only JSON + Markdown, skip layout vis
glmocr parse image.png --no-layout-vis --output ./results/
Batch processing
bash
# All images in a folder
glmocr parse ./invoice_scans/ --output ./parsed/ --no-layout-vis

# With progress visible in logs
glmocr parse ./docs/ --output ./parsed/ --log-level INFO
Debugging
bash
glmocr parse image.png --log-level DEBUG
Show full SKILL.md (178 more words)Show less
Full flag reference
FlagDefaultDescription
--api-key / -kenv varAPI key for MaaS mode (overrides ZHIPU_API_KEY)
--modemaasmaas (cloud, default) or selfhosted (local GPU)
--env-fileautoPath to .env file (default: auto-discover from cwd)
--output / -o./outputOutput directory
--stdoutoffPrint JSON + Markdown to stdout
--no-saveoffSkip writing files (use with --stdout)
--json-onlyoffstdout JSON only, no Markdown
--no-layout-visoffSkip layout visualization images
--config / -cnonePath to YAML config override
--log-levelINFODEBUG / INFO / WARNING / ERROR

Typical Agent Workflow

receive document path / URL
       │
       ▼
glmocr.parse(path)            ← single call, handles PDF/image
       │
       ▼
result.to_dict()              ← safe to pass as tool output
       │
       ├── markdown_result    → hand to LLM for reading / summarization
       └── json_result        → structured extraction (tables, formulas, regions by label)
Filter by label
python
result = glmocr.parse("report.png")
regions = result.json_result[0]  # first page

tables = [r for r in regions if r["label"] == "table"]
formulas = [r for r in regions if r["label"] == "formula"]
body_text = [r for r in regions if r["label"] == "text"]
Multi-page PDF → iterate pages
python
with GlmOcr(api_key="sk-xxx") as parser:
    result = parser.parse("document.pdf")   # all pages in one PipelineResult
    for page_idx, page_regions in enumerate(result.json_result):
        print(f"Page {page_idx + 1}: {len(page_regions)} regions")
        for region in page_regions:
            print(f"  [{region['label']}] {region['content'][:60]}")
Programmatic config (no env vars)
python
from glmocr.config import GlmOcrConfig

cfg = GlmOcrConfig.from_env(
    api_key="sk-xxx",
    mode="maas",
    timeout=600,
    log_level="DEBUG",
)

Output Directory Layout

After result.save(output_dir):

output_dir/
  <image_stem>/
    <image_stem>.json         ← structured regions
    <image_stem>.md           ← full Markdown (with cropped figure images)
    imgs/                     ← cropped figures referenced in Markdown
    layout_vis/               ← layout detection overlay images (if enabled)
      <image_stem>.jpg

Common Pitfalls

  • ZHIPU_API_KEY not set: SDK defaults to MaaS mode. Without a key, parse() will fail with a clear error message and quick-fix instructions. Set via export ZHIPU_API_KEY=sk-xxx, add to a .env file, or pass --api-key sk-xxx to the CLI.
  • Large PDFs: Default timeout is 600s. For very long documents increase with timeout=1200.
  • result.json_result is a string: Happens when the model returns malformed JSON. The SDK preserves the raw string — parse or log it manually.

© zai-org, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/glmocr-sdk of zai-org/GLM-skills.

Open the folder on GitHubat commit 2ecd31c

Compare with similar skills

Glmocr SDK next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Glmocr SDK compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Glmocr SDK this skillzai-org/GLM-skills475—~2.7kAutomated safety check: NotesApache-2.0
Markitdownjimmc414/Kosmos5942 repos~1.7kAutomated safety check: PassNone
Extracting Structured DataGAIK-project/gaik-toolkit100—~3.2kAutomated safety check: PassMIT
MarkitdownImCa0/just-laws78114 repos~3.2kAutomated safety check: NotesMIT
Form Fillingplatonai/Browser41.2k—~1.1kAutomated safety check: PassApache-2.0
Code2mediatsingliuwin/autoclaw280—~956Automated safety check: PassMIT

Similar skills

  • Markitdown

    jimmc414/Kosmos

    Convert various file formats (PDF, Office documents, images, audio, web content, structured data) to Markdown optimized for LLM processing.

    594 GitHub starsUsed in 2 repos~1.7k tokens
    Documents & OfficeAuto-check passed
  • Extracting Structured Data

    GAIK-project/gaik-toolkit

    Extracts structured data — fields, tables, line items — out of documents into a validated schema using the gaik toolkit, and designs schemas that stay inside provider limits and produce checkable…

    100 GitHub stars~3.2k tokensUpdated yesterday
    Documents & OfficeAuto-check passed
  • Markitdown

    ImCa0/just-laws

    Convert files and office documents to Markdown. An agent skill from ImCa0/just-laws.

    781 GitHub starsUsed in 14 repos~3.2k tokens
    Documents & OfficeAuto-check: notes
  • Form Filling

    platonai/Browser4

    Automatically fills web forms using provided field data and can optionally submit the form.

    1.2k GitHub stars~1.1k tokensUpdated today
    Documents & OfficeAuto-check passed
  • Code2media

    tsingliuwin/autoclaw

    Universal media renderer with no fixed template — any custom layout, size or style becomes pixel-perfect images (PNG/JPEG/WebP), vector SVG, paged PDFs or animations (WebP/GIF).

    280 GitHub stars~956 tokensUpdated 1 mo ago
    Documents & OfficeAuto-check passed
  • Reportlab

    jimmc414/Kosmos

    PDF generation toolkit. An agent skill from jimmc414/Kosmos.

    594 GitHub starsUsed in 1 repo~4.2k tokens
    Documents & OfficeAuto-check passed

More from zai-org/GLM-skills

All 16 skills in this repo
  • Glmocr

    zai-org/GLM-skills

    Extract text from images using GLM-OCR API. An agent skill from zai-org/GLM-skills.

    475 GitHub stars~1.1k tokensUpdated 5 mo ago
    Auto-check passed
  • Glm Image Gen

    zai-org/GLM-skills

    Official skill for generating high-quality images from text prompts using ZhiPu GLM-Image API.

    475 GitHub stars~2.9k tokensUpdated 5 mo ago
    Auto-check passed
  • Glmocr Formula

    zai-org/GLM-skills

    Official skill for recognizing and extracting mathematical formulas from images and PDFs into LaTeX format using ZhiPu GLM-OCR API.

    475 GitHub stars~2.2k tokensUpdated 5 mo ago
    Auto-check passed
  • Glmocr Handwriting

    zai-org/GLM-skills

    Official skill for recognizing handwritten text from images using ZhiPu GLM-OCR API.

    475 GitHub stars~1.7k tokensUpdated 5 mo ago
    Auto-check passed
  • Glmocr Table

    zai-org/GLM-skills

    Official skill for recognizing and extracting tables from images and PDFs into Markdown format using ZhiPu GLM-OCR API.

    475 GitHub stars~1.7k tokensUpdated 5 mo ago
    Auto-check passed
  • Glmv Caption

    zai-org/GLM-skills

    Generate captions (descriptions) for images, videos, and documents using ZhiPu GLM-V multimodal model series.

    475 GitHub stars~2k tokensUpdated 5 mo ago
    Auto-check: notes

Works with

Questions about Glmocr SDK

What does Glmocr SDK do?

Trigger when: (1) User wants to extract text, tables, formulas, or structured data from images/PDFs/scanned documents, (2) User mentions "OCR", "文字识别", "文档解析", (3) User has a document (screenshot…. Glmocr SDK is an agent skill from zai-org/GLM-skills. Trigger when: (1) User wants to extract text, tables, formulas, or structured data from images/PDFs/scanned documents, (2) User mentions "OCR", "文字识别", "文档解析", (3) User has a document (screenshot, scanned page, invoice, paper, whiteboard photo) and needs its content in structured form, (4) User asks to parse, digitize, or extract content from a visual document.

When should I use Glmocr SDK?

Glmocr SDK fits situations like: user wants to extract text; structured data from images/PDFs/scanned documents; user mentions OCR; user has a document (screenshot.

How do I install Glmocr SDK in Claude Code?

Run `npx skills add zai-org/GLM-skills --skill glmocr-sdk -a claude-code`. Or copy the skill folder (skills/glmocr-sdk in zai-org/GLM-skills) into .claude/skills/glmocr-sdk in your project. Claude Code loads it when a task matches its description.

How do I install Glmocr SDK in Codex?

Run `npx skills add zai-org/GLM-skills --skill glmocr-sdk -a codex`. Or copy the skill folder (skills/glmocr-sdk in zai-org/GLM-skills) into .agents/skills/glmocr-sdk in your project. Codex loads it when a task matches its description.

Can I use Glmocr SDK in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add zai-org/GLM-skills --skill glmocr-sdk -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/glmocr-sdk, .gemini/skills/glmocr-sdk, .github/skills/glmocr-sdk and .opencode/skills/glmocr-sdk in your project.

What does Glmocr SDK need to run?

Going by SKILL.md and its folder, Glmocr SDK needs the command-line tools its instructions call (pip and jq) and credentials named ZHIPU_API_KEY. Our summary lists: Python 3; A credential in ZHIPU_API_KEY.

Does Glmocr SDK access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Glmocr SDK safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Glmocr SDK use?

Glmocr SDK is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Glmocr SDK use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Glmocr SDK?

Skills that share tags, products or a category with Glmocr SDK: Markitdown (jimmc414/Kosmos, 594 stars), Extracting Structured Data (GAIK-project/gaik-toolkit, 100 stars), Markitdown (ImCa0/just-laws, 781 stars) and Form Filling (platonai/Browser4, 1.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Glmocr SDK?

zai-org (a GitHub organization) maintains it in zai-org/GLM-skills, which has 475 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on April 15, 2026.

Source: zai-org/GLM-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.