MinerU FastAPI Pipeline: Feature Enable/Disable Parameters#
Overview#
The MinerU FastAPI server exposes three boolean flags that control which processing stages execute during a document parse job. These flags are accepted as multipart form fields on every parse request and propagate through the full pipeline:
| Parameter | Default | Description |
|---|---|---|
formula_enable | true | Enable formula detection (MFD) and recognition (MFR) |
table_enable | true | Enable table structure recognition |
image_analysis | true | Enable image/chart analysis (VLM and hybrid backends only) |
The parameters are defined in mineru/cli/api_request.py and served by mineru/cli/fast_api.py.
Request Entry Points#
Both parse endpoints share the same parse_request_form FastAPI dependency, which validates inputs and constructs a ParseRequestOptions dataclass:
POST /file_parse— synchronous; waits for the task to complete and returns results inlinePOST /tasks— asynchronous; returns a task ID immediately; results polled viaGET /tasks/{task_id}/result
formula_enable and table_enable apply to all backends. image_analysis applies only to VLM and hybrid backends — the form description explicitly states: "Hybrid medium effort automatically disables image/chart analysis."
Parameter Flow#
Parameters stored in ParseRequestOptions (or AsyncParseTask for async jobs) are forwarded unchanged to run_parse_job(), which calls either do_parse or aio_do_parse in common.py .
The three flags are then routed differently per backend inside do_parse() / aio_do_parse():
Pipeline backend#
formula_enable and table_enable are passed as direct function arguments through _process_pipeline() → pipeline_doc_analyze_streaming() → batch_image_analyze(). Inside BatchAnalyze, the values are resolved via helper functions that allow environment-variable overrides: MINERU_FORMULA_ENABLE and MINERU_TABLE_ENABLE (checked in config_reader.py). image_analysis has no effect on the pipeline backend.
VLM backend#
Before calling _process_vlm(), do_parse writes both flags to the process environment :
os.environ['MINERU_VLM_FORMULA_ENABLE'] = str(formula_enable)
os.environ['MINERU_VLM_TABLE_ENABLE'] = str(table_enable)
image_analysis is then passed as an explicit keyword argument through to vlm_doc_analyze() .
Hybrid backend#
The hybrid backend has an asymmetric pattern :
table_enableis set viaos.environ['MINERU_VLM_TABLE_ENABLE']MINERU_VLM_FORMULA_ENABLEis hard-coded to"true"— formula detection is always enabled at the VLM layer for hybridformula_enableis passed directly asinline_formula_enable, controlling inline-formula merging in the pipeline layout stageimage_analysisis passed through explicitly;mediumeffort unconditionally overrides it toFalseinside the backend via_resolve_effective_image_analysis
Environment Variable Overrides#
The API-level flags can be overridden server-side via process-level environment variables:
| Env var | Scope | Overrides |
|---|---|---|
MINERU_FORMULA_ENABLE | Pipeline backend | formula_enable |
MINERU_TABLE_ENABLE | Pipeline backend | table_enable |
MINERU_VLM_FORMULA_ENABLE | VLM/Hybrid backends | formula_enable |
MINERU_VLM_TABLE_ENABLE | VLM/Hybrid backends | table_enable |
These env vars are written per-request by do_parse/aio_do_parse, so they reflect the current request's flags. Because they are process globals, race conditions are possible when MINERU_API_MAX_CONCURRENT_REQUESTS > 1.
Async Task Storage#
For async jobs, all three flags are stored directly on the AsyncParseTask dataclass alongside backend, effort, page range, and output flags. This allows the task manager to replay all parameters when the worker picks up the task from the queue.
Key Source Files#
| File | Role |
|---|---|
mineru/cli/api_request.py | Form parameter definitions and validation (ParseRequestOptions) |
mineru/cli/fast_api.py | FastAPI app, endpoints, AsyncParseTask, run_parse_job() |
mineru/cli/common.py | do_parse / aio_do_parse — backend routing and env-var injection |
mineru/utils/config_reader.py | get_formula_enable(), get_table_enable() — env-var resolution for pipeline backend |
mineru/backend/pipeline/batch_analyze.py | BatchAnalyze — pipeline-backend model init, reads formula/table flags |
mineru/cli/backend_options.py | Default values: DEFAULT_BACKEND = "hybrid-engine", DEFAULT_HYBRID_EFFORT = "medium" |