OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Feature]: Support MinerU 4.x (/v1 API) — OpenViking only speaks the retired 2.x/3.x protocol

Open kc613910 opened this issue 3 weeks ago • 2 comments

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 field files, form fields passed through from pdf.mineru_bodys, return_images=true; expects {"status": "completed", "results": {"<name>": {"md_content": ..., "images": ...}}}.
  • Startup preflight (openviking/service/mineru_preflight.py) polls GET {pdf.mineru_endpoint}/health and requires HTTP 200 with a non-empty protocol_version and status == "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 /health and no protocol_version field at all.
  • POST /v1/file_parse (sync wrapper), plus job-based POST /v1/uploads → POST /v1/parse/jobs → GET /v1/files, GET /v1/tiers (/v1/tasks with JSON manifests in later 4.1.x).
  • backend is replaced by tier (flash/basic/standard/advanced), plus ocr_mode and explicit output_formats (markdown/ZIP). Bearer auth is optional (--api-key).
  • Migration guide, explicitly: "Legacy /file_parse and /tasks are 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:

  1. 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. (/health is a 404 on 4.x, so the preflight can never pass — core.py hard-aborts for strategy == "mineru".)
  2. 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.
  3. 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:

  1. Preflight (openviking/service/mineru_preflight.py): probe /v1/health first, fall back to /health. Accept {"status": "ok"|"healthy"} and treat version / features as the capability signal instead of requiring protocol_version. Surface the detected protocol in the error message when both probes fail.

  2. Parser (openviking/parse/parsers/pdf.py): add a V1 code path — sync POST /v1/file_parse for 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.

  3. Config (openviking_cli/utils/config/parser_config.py::PdfParserConfig): add mineru_api_mode: "auto" | "v1" | "legacy" and a Bearer mineru_token (hosted MinerU and any 4.x instance started with --api-key need it), plus real fields for the 4.x knobs: mineru_tier, mineru_ocr_mode, mineru_output_formats.

  4. Semantics, not just URLs. The legacy pass-through dict mineru_bodys has no clean 4.x equivalent, so it needs an explicit mapping table and a validation error when a user sends a legacy field under api_mode: "v1":

    today (mineru_bodys, 2.x/3.x form fields) MinerU 4.x /v1
    backend tier (flash/basic/standard/advanced)
    return_images output_formats / ZIP result
    — ocr_mode (new)
    formula_enable, table_enable, lang_list no equivalent — must be rejected or warn-and-drop
  5. 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 <4 and 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/v4 service 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

kc613910 avatar Nov 10 '26 07:11 kc613910

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.

q2000s avatar Nov 24 '26 07:11 q2000s

https://github.com/volcengine/OpenViking/pull/5967

qin-ctx avatar Nov 26 '26 09:11 qin-ctx