[Feature]: Support MinerU 4.x (/v1 API) — OpenViking only speaks the retired 2.x/3.x protocol
Issue Origin
Observed or reproduced in a real environment
Problem Statement
OpenViking's mineru PDF strategy is hard-wired to the legacy MinerU 2.x/3.x self-hosted
contract, which MinerU removed in 4.0. Any MinerU >= 4.0 deployment (I'm on 4.0.12)
is therefore unusable, and the failure is not an obvious one.
What the current parser does today (openviking/parse/parsers/pdf.py::_convert_mineru):
POST {pdf.mineru_endpoint}/file_parse— multipart fieldfiles, form fields passed through frompdf.mineru_bodys,return_images=true; expects{"status": "completed", "results": {"<name>": {"md_content": ..., "images": ...}}}.- Startup preflight (
openviking/service/mineru_preflight.py) pollsGET {pdf.mineru_endpoint}/healthand requires HTTP 200 with a non-emptyprotocol_versionandstatus == "healthy".
What MinerU 4.0.12 actually serves (mineru/kit/router/app.py, the "MinerU V1 Router"):
GET /v1/health→{"status": "ok", "version": ..., "features": {...}}. There is no bare/healthand noprotocol_versionfield at all.POST /v1/file_parse(sync wrapper), plus job-basedPOST /v1/uploads→POST /v1/parse/jobs→GET /v1/files,GET /v1/tiers(/v1/taskswith JSON manifests in later 4.1.x).backendis replaced bytier(flash/basic/standard/advanced), plusocr_modeand explicitoutput_formats(markdown/ZIP). Bearer auth is optional (--api-key).- Migration guide, explicitly: "Legacy
/file_parseand/tasksare not provided." (https://opendatalab.github.io/MinerU/usage/compatibility/)
Observed failure modes with mineru[core]==4.0.12 serving on http://127.0.0.1:8000:
strategy: "mineru"— OpenViking refuses to start:RuntimeError: MinerU startup preflight failed for http://127.0.0.1:8000/health after 5.0s. Last error: ... Start a compatible mineru-api service or correct pdf.mineru_endpoint.(/healthis a 404 on 4.x, so the preflight can never pass —core.pyhard-aborts forstrategy == "mineru".)strategy: "auto"— startup logs only an advisory warning, then silently falls back to pdfplumber. Documents get ingested with far lower table/formula fidelity and nothing tells you MinerU was never consulted.- With the preflight satisfied by a proxy/stub, the parse itself dies at
response.raise_for_status()—POST /file_parse→ 404 Not Found.
There is also no documented compatibility statement anywhere: grep for a MinerU version
constraint across docs/, requirements and examples/ov.conf.example returns nothing. The
docs only say "a synchronous POST {mineru_endpoint}/file_parse request"
(docs/en/guides/01-configuration.md, "MinerU protocol"), so a user following the guide with
a current MinerU release has no way to know they are being pointed at an API generation that
no longer exists.
Proposed Solution
Add the MinerU V1 (/v1/*) protocol as a supported flavour, alongside the legacy one, and
make the choice explicit rather than guessed:
-
Preflight (
openviking/service/mineru_preflight.py): probe/v1/healthfirst, fall back to/health. Accept{"status": "ok"|"healthy"}and treatversion/featuresas the capability signal instead of requiringprotocol_version. Surface the detected protocol in the error message when both probes fail. -
Parser (
openviking/parse/parsers/pdf.py): add a V1 code path — syncPOST /v1/file_parsefor parity with today's behaviour, and (optionally, behind the same switch) the job flow/v1/uploads→/v1/parse/jobs→ poll → download/v1/files, reusing the existing media-store image handling for ZIP output. -
Config (
openviking_cli/utils/config/parser_config.py::PdfParserConfig): addmineru_api_mode: "auto" | "v1" | "legacy"and a Bearermineru_token(hosted MinerU and any 4.x instance started with--api-keyneed it), plus real fields for the 4.x knobs:mineru_tier,mineru_ocr_mode,mineru_output_formats. -
Semantics, not just URLs. The legacy pass-through dict
mineru_bodyshas no clean 4.x equivalent, so it needs an explicit mapping table and a validation error when a user sends a legacy field underapi_mode: "v1":today ( mineru_bodys, 2.x/3.x form fields)MinerU 4.x /v1backendtier(flash/basic/standard/advanced)return_imagesoutput_formats/ ZIP result— ocr_mode(new)formula_enable,table_enable,lang_listno equivalent — must be rejected or warn-and-drop -
Docs: state the supported MinerU version range per protocol in
docs/{en,zh}/guides/01-configuration.md, and until V1 lands, document the interim pin (mineru[core]>=3.4,<4+mineru-api) so users on 4.x aren't left to infer it from a 404.
I'd keep this separate from the mineru.net cloud work (#5967): different host, different
auth, different task model, and /health-less async only.
Alternatives Considered
- Pin MinerU to
<4and document it as the supported range. Works today, but MinerU's current line is 4.1.x, so OpenViking is pinned to an API generation that upstream has deleted. - Use the hosted
mineru.net/api/v4service via #4708 / #5967 — that is a third protocol (async-only, token-authed), does not help a self-hosted 4.0.12 deployment, and raises data egress concerns for internal documents. - Stay on pdfplumber (
strategy: "local"). Acceptable for plain text, but that's the whole reason MinerU support exists: tables, formulas and complex layout. - Drop MinerU entirely as drafted in #3966 / #3957 — not what I want, just noting it as the implicit status quo if the protocol gap stays open.
Feature Area
Other
Use Case
Self-hosted OpenViking ingesting PDF-heavy internal knowledge bases (contracts, datasheets, scanned reports with multi-column layout, tables and inline formulas). MinerU is the reason those parse acceptably; pdfplumber silently degrades the knowledge base. The deployment has to track MinerU releases for model and security updates, so freezing on 3.x isn't an option, and the whole knowledge base has to be re-ingested when the parser silently falls back.
Example API (Optional)
Additional Context
No response
Contribution
- [x] I am willing to contribute to implementing this feature
I made the PR #5967 , and it has been working for me for a while. Given the code-reviewing and merging processes from the maintainer group of this project take a while, I suggest you having a try with the PR as a patch to your local installation. Also, replacing the remote service API with your local host of MinerU is possible by replacing the remote URL with a local one.
https://github.com/volcengine/OpenViking/pull/5967