Skip to main content

mineru2md

使用 MinerU API 将 PDF 文件转换为 Markdown 的命令行工具。

功能

  • 🚀 单个命令将本地 PDF 转为 Markdown
  • 🎯 支持 免费模式(无需 API Key,限制 10MB / 20 页)
  • 🔑 支持 精准解析模式(配置 MINERU_API_KEY 后自动启用,最高支持 200MB / 600 页)
  • 📁 输出 Markdown 文件默认与源 PDF 同名、同目录
  • 🔄 自动重试(最多 3 次,指数退避)
  • ⚡ 若目标 Markdown 已存在则跳过,避免重复转换

环境要求

  • Python >= 3.11
  • uv 包管理工具(推荐),或 pip

安装

方式一:通过 uv 全局安装(推荐)

uv tool install mineru2md

方式二:通过 pip 安装

pip install mineru2md

方式三:从源码安装

git clone <repo-url>
cd mineru-cli
uv tool install .

安装成功后,mineru 命令即可在终端直接使用。

环境变量配置

变量名 必填 说明
MINERU_API_KEY 否 MinerU 精准解析 API 的 Token。未设置时使用免费 Agent API

获取 API Key

  1. 访问 MinerU 官网 注册/登录
  2. 进入个人中心或 API 管理页面,申请 Token
  3. 将 Token 设置为环境变量:

macOS / Linux:

export MINERU_API_KEY="your-api-token"

可将该行添加到 ~/.zshrc 或 ~/.bashrc 中持久化。

Windows(PowerShell):

$env:MINERU_API_KEY="your-api-token"

两种模式对比

维度 免费模式(无 API Key) 精准解析模式(有 API Key)
API 接口 /api/v1/agent /api/v4
文件大小限制 ≤ 10 MB ≤ 200 MB
页数限制 ≤ 20 页 ≤ 600 页
模型 pipeline 轻量模型 vlm 模型
输出格式 Markdown Zip 包(含 Markdown、JSON 等)

使用方法

mineru <pdf路径> [-o 输出目录]

参数说明

参数 说明
pdf_path (必填)本地 PDF 文件路径
-o, --output-dir (可选)输出目录,默认为 PDF 文件所在目录

示例

# 基本用法:将 example.pdf 转为 example.md(输出到同目录)
mineru ./example.pdf

# 指定输出目录
mineru ./example.pdf -o ./output

# 配合环境变量使用精准解析
export MINERU_API_KEY="your-token"
mineru ./large-document.pdf

开发

# 克隆项目
git clone <repo-url>
cd mineru-cli

# 创建虚拟环境并安装依赖
uv sync

# 直接运行
python main.py ./example.pdf

技术栈

  • Python 3.11+
  • requests — HTTP 客户端
  • uv — 包管理与构建

License

MIT

Metadata

Release files for mineru2md 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mineru2md 0.1.1
File Size Uploaded Provenance
mineru2md-0.1.1.tar.gz 7.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mineru2md 0.1.1
File Interpreter ABI Platform
mineru2md-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / mineru2md-0.1.1.tar.gz

Download URL mineru2md-0.1.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
723a0a01f72f17919cf47030ec9c167b77d933798d3c60c82f1cbfea805cbc8a
BLAKE2b-256 checksum
How to use checksums
288cb969ac07681fe22508bb3927aedab2ab3f7323108a86ddabe62d39c6bc11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mineru2md-0.1.1-py3-none-any.whl

Download URL mineru2md-0.1.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
096c68c0ceb1ffad68c1e40b4e81e2fca0fad6ab7abf973979d0ee7d5a1c6e9b
BLAKE2b-256 checksum
How to use checksums
13289ae30313bb52a976cf7f6e147fd03e01d08596edbadfafddb3ef6d3763c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mineru2md 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page