zai-ocr-skill

zai-ocr-skill is a skill for OpenCode from darellchua2/opencode-config-template. It costs 52 tokens per session (1,398 once invoked), scanned A, original, Apache-2.0.

A document-reading recipe that extracts text and layout from images or PDFs through Z.AI’s GLM-OCR service. It keeps reading order, blocks, and tables structured.

In plain words
What is it for?
Use it to turn scanned documents or PDFs into structured text for later processing.
Why use it?
It helps when plain image descriptions lose the document’s structure, making dense pages and tables harder to use.

Skill for OpenCode

Written for OpenCode: installed under .opencode/. Also seen: mentions OpenCode.

Good fit Use it to turn scanned documents or PDFs into structured text for later processing.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/darellchua2/opencode-config-template/zai-ocr-skill
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add darellchua2/opencode-config-template --skill zai-ocr-skill
Clone the repo
git clone --depth 1 https://github.com/darellchua2/opencode-config-template

Made for: OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for zai-ocr-skill

README.md
[![agentmods](https://agentmods.dev/badge/skills/darellchua2/opencode-config-template/zai-ocr-skill.svg)](https://agentmods.dev/skills/darellchua2/opencode-config-template/zai-ocr-skill)
Your own site
<a href="https://agentmods.dev/skills/darellchua2/opencode-config-template/zai-ocr-skill"><img src="https://agentmods.dev/badge/skills/darellchua2/opencode-config-template/zai-ocr-skill.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,398 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 6 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Supply Chain · line 46
    Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
    Fix: Avoid downloading and executing remote scripts. Use trusted packages from PyPI/npm. If remote fetch is required, verify checksums and use HTTPS.
  • high Supply Chain · line 75
    Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
    Fix: Avoid downloading and executing remote scripts. Use trusted packages from PyPI/npm. If remote fetch is required, verify checksums and use HTTPS.
  • medium Data Exfiltration · line 46
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 75
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 44
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 72
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.01398
Opus 5 $0.00026 $0.00699
Sonnet 5 $0.00010 $0.00280
Haiku 4.5 $0.00005 $0.00140

Measured 4d ago against content hash 193810735cb6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

zai-ocr-skill scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

RESP=$(curl -sS --max-time 180 -X POST "$BASE/layout_parsing" \
opencode_app/.opencode/skills/zai-ocr-skill/SKILL.md · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

What I do

I provide the exact recipe for an agent to extract text with layout structure from an image or PDF via the Z.AI GLM-OCR layout_parsing API. Unlike a vision-chat description, the dedicated endpoint returns the document's text organized by detected layout (blocks, reading order, tables).

Why a skill (not vision chat)

  • POST /layout_parsing is a dedicated document-extraction endpoint — richer and more faithful for dense/structured documents than asking a chat model to describe an image.
  • Input is an http(s) URL. Base64 is documented in the API schema but every base64 form is rejected server-side with code 1214 (verified 2026-08-30: png/jpeg/pdf × raw/data-URI/padded/unpadded) — local files use the vision fallback in Path B.

Prerequisite — API key resolution

KEY="${ZAI_API_KEY:-$(jq -r '.["zai"].key // .["zai-coding-plan"].key // empty' \
     ~/.local/share/opencode/auth.json 2>/dev/null)}"
[ -z "$KEY" ] && { echo "ZAI_API_KEY not found — set it (export ZAI_API_KEY) or run \`opencode auth login\` (Z.AI)."; exit 1; }

If neither source has the key, stop and report — do not proceed.

Recipe

Path A — file already has a public URL (full layout result)

FILE_URL="https://example.com/document.png"           # REQUIRED — public http(s) URL, png/jpg/pdf
BASE="${ZAI_MEDIA_ENDPOINT:-https://api.z.ai/api/paas/v4}"  # pay-as-you-go ONLY

RESP=$(curl -sS --max-time 180 -X POST "$BASE/layout_parsing" \
  -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
  -d "{\"model\":\"glm-ocr\",\"file\":\"$FILE_URL\"}")

printf '%s' "$RESP" | python3 -c '
import sys, json
d = json.load(sys.stdin)
if d.get("error"):
    sys.stderr.write("API error: " + json.dumps(d["error"]) + "\n"); sys.exit(1)
print(d.get("md_results") or "(empty md_results)")
for page in d.get("layout_details", []):
    for el in page:
        print("[" + str(el.get("label", "")) + "] " + str(el.get("content", "")))'

Output: md_results (markdown of the whole document) plus one [label] content line per layout element (text/table/formula/image) on stdout.

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 117 lines · 52 tokens per session scan A 193810735cb6

Subscribe to this mod's changes

zai-ocr-skill is a skill published in the GitHub repository darellchua2/opencode-config-template (6 stars, last pushed yesterday), licensed Apache-2.0. It adds 52 tokens to every session and 1,398 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.