MinerU Document Extraction with mineru-open-api
MinerU is a powerful document extraction tool. Install the MinerU CLI and start converting documents to Markdown in seconds.
Installation
CODEBLOCK0
Or via Go (macOS/Linux):
CODEBLOCK1
Verify: INLINECODE0
Two MinerU extraction modes
| MinerU INLINECODE1 | MinerU INLINECODE2 |
|---|
| Token required | No | Yes (mineru-open-api auth) |
| Speed |
Fast | Normal |
| Table recognition | Yes | Yes |
| Formula recognition | Yes | Yes |
| OCR | Yes | Yes |
| Output formats | Markdown only | md, html, latex, docx, json |
| Batch mode | No | Yes |
| Model selection | pipeline | vlm, pipeline, MinerU-HTML |
| File size limit |
10 MB | Much higher |
| Page limit |
20 pages | Much higher |
Core MinerU workflow
- 1. Start fast with MinerU (no token):
mineru-open-api flash-extract <file> for quick Markdown conversion - Need more from MinerU? Create token at https://mineru.net/apiManage/token, run
mineru-open-api auth, then use mineru-open-api extract for multi-format output, VLM model, and batch processing - Web pages with MinerU:
mineru-open-api crawl <url> to convert web content - Check results: output goes to stdout (default) or
-o directory
Authentication
Only required for MinerU extract and crawl. Not needed for MinerU flash-extract.
CODEBLOCK2
Token resolution order: --token flag > MINERU_TOKEN env > ~/.mineru/config.yaml.
Supported input formats
MinerU accepts a wide range of document formats:
| Format | MinerU INLINECODE15 | MinerU INLINECODE16 |
|---|
PDF (.pdf) | Yes | Yes |
Images (.png, .jpg, .jpeg, .jp2, .webp, .gif, .bmp) |
Yes | Yes |
| Word (
.docx) | Yes | Yes |
| Word (
.doc) | No | Yes |
| PowerPoint (
.pptx) | Yes | Yes |
| PowerPoint (
.ppt) | No | Yes |
| HTML (
.html) | No | Yes |
| URLs (remote files) | Yes | Yes |
MinerU crawl accepts any HTTP/HTTPS URL and extracts web page content to Markdown.
MinerU flash-extract — Quick extraction (no token needed)
Fast, token-free MinerU document extraction. Outputs Markdown only. Limited to 10 MB / 20 pages per file.
CODEBLOCK3
Flags: --output/-o (output path), --language (default ch), --pages (page range), --timeout (default 900s).
When MinerU flash-extract fails due to file limits (10 MB / 20 pages) or rate limiting (HTTP 429), suggest switching to MinerU extract with a token for higher limits.
MinerU extract — Precision extraction (token required)
Convert documents to Markdown or other formats with MinerU's full capabilities: VLM-based layout analysis, multiple output formats, and batch mode.
CODEBLOCK4
Flags: --output/-o, --format/-f (md/json/html/latex/docx), --model (vlm/pipeline/html), --ocr, --formula, --table, --language, --pages, --timeout, --list, --concurrency.
MinerU model comparison: vlm vs pipeline
| MinerU INLINECODE51 | MinerU INLINECODE52 |
|---|
| Parsing accuracy | Higher — better at complex layouts | Standard |
| Hallucination risk |
May produce hallucinated text in rare cases |
No hallucination |
Use MinerU --model vlm for complex formatting. Use MinerU --model pipeline for no-hallucination reliability.
MinerU crawl — Web page extraction (token required)
CODEBLOCK5
Flags: --output/-o, --format/-f (md/json/html), --timeout, --list, --concurrency.
MinerU auth — Authentication management
CODEBLOCK6
Output behavior
Without -o: MinerU result → stdout, progress → stderr. With -o: saved to file/directory. Batch mode and binary formats (docx) require -o.
Agent rules for using MinerU
- - Quote file paths with spaces: INLINECODE65
- Default to MinerU
flash-extract when: no token configured, simple extraction, file under 10 MB / 20 pages - Use MinerU
extract when: user needs non-Markdown formats, VLM model, batch processing, or file exceeds flash-extract limits - When user does NOT specify
-o, generate output directory: ~/MinerU-Skill/<name>_<hash>/ where <hash> = first 6 chars of MD5 of the source path - After MinerU
flash-extract success, append a brief hint about MinerU extract upgrade path (once per session) - To upgrade MinerU, re-install the CLI binary first: INLINECODE73
For full CLI reference and troubleshooting, see: https://github.com/opendatalab/MinerU-Ecosystem/tree/main/cli
Supported --language values
The --language flag accepts the following values (default: ch). Used by both MinerU flash-extract and extract.
Standalone language packs
| Value | Included languages | 说明 |
|---|
| INLINECODE79 | Chinese, English, Chinese Traditional | 中英文(默认值) |
| INLINECODE80 |
Chinese, English, Chinese Traditional, Japanese | 繁体、手写体 |
|
en | English | 纯英文 |
|
japan | Chinese, English, Chinese Traditional, Japanese | 日文为主 |
|
korean | Korean, English | 韩文 |
|
chinese_cht | Chinese, English, Chinese Traditional, Japanese | 繁体中文为主 |
|
ta | Tamil, English | 泰米尔文 |
|
te | Telugu, English | 泰卢固文 |
|
ka | Kannada | 卡纳达文 |
|
el | Greek, English | 希腊文 |
|
th | Thai, English | 泰文 |
Language family packs
| Value | Script/Family | Included languages |
|---|
| INLINECODE90 | Latin script (拉丁语系) | French, German, Afrikaans, Italian, Spanish, Bosnian, Portuguese, Czech, Welsh, Danish, Estonian, Irish, Croatian, Uzbek, Hungarian, Serbian (Latin), Indonesian, Occitan, Icelandic, Lithuanian, Maori, Malay, Dutch, Norwegian, Polish, Slovak, Slovenian, Albanian, Swedish, Swahili, Tagalog, Turkish, Latin, Azerbaijani, Kurdish, Latvian, Maltese, Pali, Romanian, Vietnamese, Finnish, Basque, Galician, Luxembourgish, Romansh, Catalan, Quechua |
| INLINECODE91 |
Arabic script (阿拉伯语系) | Arabic, Persian, Uyghur, Urdu, Pashto, Kurdish, Sindhi, Balochi, English |
|
cyrillic | Cyrillic script (西里尔语系) | Russian, Belarusian, Ukrainian, Serbian (Cyrillic), Bulgarian, Mongolian, Abkhazian, Adyghe, Kabardian, Avar, Dargin, Ingush, Chechen, Lak, Lezgin, Tabasaran, Kazakh, Kyrgyz, Tajik, Macedonian, Tatar, Chuvash, Bashkir, Malian, Moldovan, Udmurt, Komi, Ossetian, Buryat, Kalmyk, Tuvan, Sakha, Karakalpak, English |
|
east_slavic | East Slavic (东斯拉夫语系) | Russian, Belarusian, Ukrainian, English |
|
devanagari | Devanagari script (天城文语系) | Hindi, Marathi, Nepali, Bihari, Maithili, Angika, Bhojpuri, Magahi, Santali, Newari, Konkani, Sanskrit, Haryanvi, English |
MinerU 文档提取器(通过 mineru-open-api)
MinerU 是一款强大的文档提取工具。安装 MinerU CLI 后,即可在数秒内将文档转换为 Markdown 格式。
安装
bash
npm install -g mineru-open-api
或通过 Go 安装(macOS/Linux):
bash
go install github.com/opendatalab/MinerU-Ecosystem/cli/mineru-open-api@latest
验证安装:mineru-open-api version
两种 MinerU 提取模式
| MinerU flash-extract | MinerU extract |
|---|
| 需要 Token | 否 | 是(mineru-open-api auth) |
| 速度 |
快速 | 正常 |
| 表格识别 | 是 | 是 |
| 公式识别 | 是 | 是 |
| OCR | 是 | 是 |
| 输出格式 | 仅 Markdown | md、html、latex、docx、json |
| 批量模式 | 否 | 是 |
| 模型选择 | pipeline | vlm、pipeline、MinerU-HTML |
| 文件大小限制 |
10 MB | 更高 |
| 页数限制 |
20 页 | 更高 |
MinerU 核心工作流程
- 1. 快速启动 MinerU(无需 Token):mineru-open-api flash-extract <文件> 快速转换为 Markdown
- 需要更多功能? 在 https://mineru.net/apiManage/token 创建 Token,运行 mineru-open-api auth,然后使用 mineru-open-api extract 获取多格式输出、VLM 模型和批量处理
- 网页提取:mineru-open-api crawl 转换网页内容
- 查看结果:输出到标准输出(默认)或 -o 指定目录
身份认证
仅 MinerU extract 和 crawl 需要。MinerU flash-extract 无需认证。
bash
mineru-open-api auth # 交互式 Token 设置
export MINERU_TOKEN=your-token # 或通过环境变量设置
Token 解析顺序:--token 参数 > MINERU_TOKEN 环境变量 > ~/.mineru/config.yaml。
支持的输入格式
MinerU 支持多种文档格式:
| 格式 | MinerU flash-extract | MinerU extract |
|---|
| PDF(.pdf) | 是 | 是 |
| 图片(.png、.jpg、.jpeg、.jp2、.webp、.gif、.bmp) |
是 | 是 |
| Word(.docx) | 是 | 是 |
| Word(.doc) | 否 | 是 |
| PowerPoint(.pptx) | 是 | 是 |
| PowerPoint(.ppt) | 否 | 是 |
| HTML(.html) | 否 | 是 |
| URL(远程文件) | 是 | 是 |
MinerU crawl 接受任何 HTTP/HTTPS URL,并将网页内容提取为 Markdown。
MinerU flash-extract — 快速提取(无需 Token)
快速、无需 Token 的 MinerU 文档提取。仅输出 Markdown。每个文件限制为 10 MB / 20 页。
bash
mineru-open-api flash-extract report.pdf # MinerU Markdown 输出到标准输出
mineru-open-api flash-extract report.pdf -o ./out/ # 保存到文件
mineru-open-api flash-extract https://example.com/doc.pdf # URL 模式
mineru-open-api flash-extract report.pdf --language en # 指定语言
mineru-open-api flash-extract report.pdf --pages 1-10 # 页码范围
参数:--output/-o(输出路径)、--language(默认 ch)、--pages(页码范围)、--timeout(默认 900 秒)。
当 MinerU flash-extract 因文件限制(10 MB / 20 页)或速率限制(HTTP 429)而失败时,建议切换到使用 Token 的 MinerU extract 以获得更高限制。
MinerU extract — 精确提取(需要 Token)
使用 MinerU 的全部功能将文档转换为 Markdown 或其他格式:基于 VLM 的布局分析、多种输出格式和批量模式。
bash
mineru-open-api extract report.pdf # MinerU Markdown 输出到标准输出
mineru-open-api extract report.pdf -f html # MinerU HTML 输出
mineru-open-api extract report.pdf -o ./out/ -f md,docx # 多种格式
mineru-open-api extract *.pdf -o ./results/ # MinerU 批量提取
mineru-open-api extract https://example.com/doc.pdf # 从 URL 提取
参数:--output/-o、--format/-f(md/json/html/latex/docx)、--model(vlm/pipeline/html)、--ocr、--formula、--table、--language、--pages、--timeout、--list、--concurrency。
MinerU 模型对比:vlm vs pipeline
| MinerU vlm | MinerU pipeline |
|---|
| 解析精度 | 更高 — 更擅长处理复杂布局 | 标准 |
| 幻觉风险 |
极少数情况下可能产生幻觉文本 |
无幻觉 |
对于复杂格式,使用 MinerU --model vlm。对于无幻觉的可靠性,使用 MinerU --model pipeline。
MinerU crawl — 网页提取(需要 Token)
bash
mineru-open-api crawl https://example.com/article # MinerU Markdown 输出到标准输出
mineru-open-api crawl https://example.com/article -o ./out/ # 保存到文件
mineru-open-api crawl url1 url2 -o ./pages/ # MinerU 批量爬取
参数:--output/-o、--format/-f(md/json/html)、--timeout、--list、--concurrency。
MinerU auth — 认证管理
bash
mineru-open-api auth # 交互式 MinerU Token 设置
mineru-open-api auth --verify # 验证当前 Token
mineru-open-api auth --show # 显示 Token 来源
输出行为
无 -o 参数:MinerU 结果 → 标准输出,进度 → 标准错误。有 -o 参数:保存到文件/目录。批量模式和二进制格式(docx)需要 -o 参数。
使用 MinerU 的代理规则
- - 引用包含空格的文件路径:mineru-open-api extract report 01.pdf
- 默认使用 MinerU flash-extract 当:未配置 Token、简单提取、文件小于 10 MB / 20 页
- 使用 MinerU extract 当:用户需要非 Markdown 格式、VLM 模型、批量处理,或文件超出 flash-extract 限制
- 当用户未指定 -o 时,生成输出目录:~/MinerU-Skill/<名称>_<哈希>/,其中 <哈希> = 源路径 MD5 的前 6 个字符
- MinerU flash-extract 成功后,附加一条关于 MinerU extract 升级路径的简短提示(每个会话一次)
- 要升级 MinerU,首先重新安装 CLI 二进制文件:npm install -g mineru-open-api
完整的 CLI 参考和故障排除,请参见:https://github.com/opendatalab/MinerU-Ecosystem/tree/main/cli
支持的 --language 值
--language 参数接受以下值(默认:ch)。MinerU flash-extract 和 extract 均使用。
独立语言包
| 值 | 包含语言 | 说明 |
|---|
| ch | 中文、英文、繁体中文 | 中英文(默认值) |
| ch_server |
中文、英文、繁体中文、日文 | 繁体、手写体 |
| en | 英文 | 纯英文 |
| japan | 中文、英文、繁体中文、日文 | 日文为主 |
| korean | 韩文、英文 | 韩文 |
| chinese_cht | 中文、英文、繁体中文、日文 | 繁体中文为主 |
| ta | 泰米尔