Extract text from images and PDFs using the GLM-OCR layout parsing API.
ResourceLinkGet API Keyhttps://www.bigmodel.cn/usercenter/proj-mgmt/apikeysGitHubhttps://github.com/zai-org/GLM-OCR
ZHIPU_API_KEY (and optional timeout) is read from environment variables.⛔ MANDATORY RESTRICTIONS - DO NOT VIOLATE ⛔
python scripts/glm_ocr_cli.pyGet your API key: https://www.bigmodel.cn/usercenter/proj-mgmt/apikeys
Configure: bash
python scripts/config_setup.py setup --api-key YOUR_KEY
bash
python scripts/glm_ocr_cli.py --file-url "URL provided by user"
bash
python scripts/glm_ocr_cli.py --file /path/to/image.jpg
bash
python scripts/glm_ocr_cli.py --file-url "URL" --output result.json
text
python {baseDir}/scripts/glm_ocr_cli.py (--file-url URL | --file PATH) [--output FILE] [--pretty]
ParameterRequiredDescription--file-urlOne ofURL to image/PDF--fileOne ofLocal file path to image/PDF--output, -oNoSave result JSON to file--prettyNoPretty-print JSON output
json
{
"ok": true,
"text": "# Extracted text in Markdown...",
"layout_details": [[...]],
"result": { "raw_api_response": "..." },
"error": null,
"source": "/path/to/file.jpg",
"source_type": "file"
}
Key fields:
ok — whether extraction succeededtext — extracted text in Markdown (use this for display)layout_details — layout analysis detailsresult — raw API responseerror — error details on failureAPI key not configured:
text
Error: ZHIPU_API_KEY not configured. Get your API key at: https://www.bigmodel.cn/usercenter/proj-mgmt/apikeys
→ Show exact error to user, guide them to configure
Authentication failed (401/403): API key invalid/expired → reconfigure
Rate limit (429): Quota exhausted → inform user to wait
File not found: Local file missing → check path
references/output_schema.md — detailed output format specification