Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
Switch hosted endpoints to production
jinzhenj2fc6235ad8f2
diff --git a/docs/next/architecture.md b/docs/next/architecture.mdindex 6c099133..49a438fa 100644--- a/docs/next/architecture.md+++ b/docs/next/architecture.md@@ -274,7 +274,7 @@ ParseWorker 按 `tier`、`privacy` 和 parse-server 健康状态路由:|------|----------|| 未指定 tier | PDF/image 通过当前目标 parse-server 能力发现,按 `high` -> `xhigh` -> `medium` 解析;Office/text/HTML 归一为 `flash` || `tier=flash` | 直接本地调用轻量 parser,`via=local` |-| `tier=medium/high/xhigh` 且 `privacy=remote` | 优先调用 config 中的远端地址;产品正式目标是 `mineru.net/api`,当前代码默认值暂为 `https://staging.mineru.org.cn/api` |+| `tier=medium/high/xhigh` 且 `privacy=remote` | 优先调用 config 中的远端地址,默认使用 `https://mineru.net/api` || remote 不可用 | 尝试 fallback 到 local parse-server || `privacy=local` 且 local parse-server disabled | 返回 `no_engine` || local parse-server 配置但探活失败 | 返回可重试错误 |@@ -387,7 +387,7 @@ parse-server 配置:| `parse_server.local.mode` | `disabled` | `disabled` / `managed` / `self_hosted` || `parse_server.local.managed_tier` | `high` | managed 模式启动的 tier;当前允许 `medium` / `high` / `xhigh` || `parse_server.local.self_hosted_url` | 无 | self-hosted 地址 |-| `parse_server.remote.url` | 当前代码默认 `https://staging.mineru.org.cn/api` | 远端地址;产品正式目标是 `https://mineru.net/api` |+| `parse_server.remote.url` | `https://mineru.net/api` | 默认远端地址 || `parse_server.remote.api_key` | 无 | 远端 API Key |API Key 优先级:config 表中的 API Key 高于环境变量 `MINERU_API_KEY`;环境变量仅作为未配置 API Key 时的默认值。diff --git a/docs/next/config.md b/docs/next/config.mdindex eb18edd2..f131aac7 100644--- a/docs/next/config.md+++ b/docs/next/config.md@@ -120,11 +120,11 @@ SDK client 显式参数属于当前调用方传入的请求上下文;当它最|-----|--------|------|| `parse_server.local.mode` | `disabled` | 本地 parse-server 模式 || `parse_server.local.managed_tier` | `high` | managed 模式启动 tier |-| `parse_server.remote.url` | 当前代码默认 `https://staging.mineru.org.cn/api` | 默认远端 API 地址;产品正式目标是 `https://mineru.net/api` |+| `parse_server.remote.url` | `https://mineru.net/api` | 默认远端 API 地址 |## 5. Parse-server 配置-parse-server 是 `medium` / `high` / `xhigh` 等质量 tier 的解析能力来源。它可以是本地独立进程,也可以是远端 `mineru.net/api` 或当前代码配置的 staging endpoint。+parse-server 是 `medium` / `high` / `xhigh` 等质量 tier 的解析能力来源。它可以是本地独立进程,也可以是远端 `mineru.net/api`。### 5.1 Local parse-server@@ -147,7 +147,7 @@ parse-server 是 `medium` / `high` / `xhigh` 等质量 tier 的解析能力来| key | 默认值 | 说明 ||-----|--------|------|-| `parse_server.remote.url` | 当前代码默认 `https://staging.mineru.org.cn/api` | 默认远端 API 地址;产品正式目标是 `https://mineru.net/api` |+| `parse_server.remote.url` | `https://mineru.net/api` | 默认远端 API 地址 || `parse_server.remote.api_key` | 无 | 远端 API Key |远端配置存在不等于允许上传。只有当前请求显式 `--remote`,或 parsing-rule 显式带 remote 语义时,才可以上传文档。diff --git a/docs/next/telemetry-implementation-plan.md b/docs/next/telemetry-implementation-plan.mdindex 1fb159d9..9f82ec02 100644--- a/docs/next/telemetry-implementation-plan.md+++ b/docs/next/telemetry-implementation-plan.md@@ -22,10 +22,10 @@- duration bucket 不带 `error_code`。- 成功状态不带 `error_code`,不上传 `none`。-第一版外部 metrics API 先按 `aaa.py` 中 staging 接口实现:+第一版外部 metrics API 按正式接口实现:```text-POST https://staging.mineru.org.cn/metrics/v2/metrics+POST https://mineru.net/metrics/v2/metrics```请求规则:@@ -80,7 +80,7 @@ mineru/doclib/telemetry/实现内容:-- `constants.py`: metric name、dimension whitelist、`METRIC_SPECS`、consent state、endpoint、API version、schema version、staging app key/secret。+- `constants.py`: metric name、dimension whitelist、`METRIC_SPECS`、consent state、endpoint、API version、schema version、正式环境 app key/secret。- `buckets.py`: duration、pages、file size、results bucket。- `context.py`: `contextvars`、HTTP header parse、request context set/reset。- `caller.py`: parent process tree inference,最大深度 12,只读进程名。@@ -347,7 +347,7 @@ prompt helper:1. `telemetry core`: DB、store、service、payload、buckets、context。2. `telemetry api`: management API、observations API、client/base/types。-3. `telemetry flush`: worker、flush lock、staging metrics API。+3. `telemetry flush`: worker、flush lock、正式 metrics API。4. `telemetry metrics`: parse/search/content/scan/watch/ingest/parse_task 打点。5. `telemetry cli`: commands、prompt、parse wait observation。diff --git a/mineru/doclib/config_defaults.py b/mineru/doclib/config_defaults.pyindex b456574e..fbfd47ed 100644--- a/mineru/doclib/config_defaults.py+++ b/mineru/doclib/config_defaults.py@@ -11,8 +11,7 @@ CONFIG_DEFAULTS: dict[str, str] = {"parse_server.local.managed_tier": "high","parse_server.local.self_hosted_url": "","parse_server.local.self_hosted_api_key": "",- # "parse_server.remote.url": "https://mineru.net/api",- "parse_server.remote.url": "https://staging.mineru.org.cn/api",+ "parse_server.remote.url": "https://mineru.net/api","parse_server.remote.api_key": "",}diff --git a/mineru/doclib/telemetry/constants.py b/mineru/doclib/telemetry/constants.pyindex 547a313f..5e9d488b 100644--- a/mineru/doclib/telemetry/constants.py+++ b/mineru/doclib/telemetry/constants.py@@ -13,7 +13,7 @@ CONSENT_UNSET: TelemetryConsentState = "unset"CONSENT_ENABLED: TelemetryConsentState = "enabled"CONSENT_DISABLED: TelemetryConsentState = "disabled"-TELEMETRY_ENDPOINT = "https://staging.mineru.org.cn/metrics/v2/metrics"+TELEMETRY_ENDPOINT = "https://mineru.net/metrics/v2/metrics"TELEMETRY_APP_KEY = "213a83db-44c8-4218-90c0-ded685cca86e"TELEMETRY_APP_SECRET = "sec_5f8d9a2b"TELEMETRY_API_VERSION = "v2"diff --git a/mineru/parser/api_client.py b/mineru/parser/api_client.pyindex 4776e56d..c09f8ff1 100644--- a/mineru/parser/api_client.py+++ b/mineru/parser/api_client.py@@ -719,13 +719,13 @@ def _extract_model_output_from_archive(archive: zipfile.ZipFile) -> Any | None:if local_name in names:model_output_name = local_nameelse:- staging_names = sorted(name for name in names if Path(name).name.endswith("_model.json"))- if not staging_names:+ legacy_names = sorted(name for name in names if Path(name).name.endswith("_model.json"))+ if not legacy_names:return None- if len(staging_names) > 1:- available = ", ".join(staging_names)+ if len(legacy_names) > 1:+ available = ", ".join(legacy_names)raise _V1APIError("invalid_model_output", f"ZIP output contained multiple model outputs: {available}")- model_output_name = staging_names[0]+ model_output_name = legacy_names[0]raw = archive.read(model_output_name)try:@@ -794,7 +794,7 @@ def _middle_json_zip_candidates() -> list[str]:def _read_middle_json_from_zip(archive: zipfile.ZipFile) -> dict[str, Any]:- """从本地 api_server 或 staging remote server 的 zip 中读取 middle_json。"""+ """从本地 api_server 或 remote server 的 zip 中读取 middle_json。"""names = set(archive.namelist())for candidate in _middle_json_zip_candidates():if candidate not in names:@@ -957,7 +957,7 @@ def _parse_result_from_middle_json(mid_json: dict[str, Any]) -> ParseResult:pdf_info = mid_json.get("pdf_info")if isinstance(pdf_info, list):- # Staging JSON output may use the older pdf_info field instead of ParseResult pages.+ # The official API may use the older pdf_info field instead of ParseResult pages.compat_payload = dict(mid_json)compat_payload["pages"] = pdf_inforeturn ParseResult.from_dict(compat_payload)@@ -1017,7 +1017,7 @@ def _structured_error(data: dict[str, Any]) -> dict[str, Any] | None:def _remote_auth_message(data: dict[str, Any]) -> str | None:msg_code = data.get("msgCode")msg = data.get("msg")- # Staging auth failures still use the legacy msgCode/msg payload instead of {"error": ...}.+ # Official API auth failures may use the legacy msgCode/msg payload instead of {"error": ...}.if msg_code == "A0202":return str(msg or "user authenticate failed")if isinstance(msg, str) and "authenticate failed" in msg.lower():diff --git a/tests/unittest/test_doclib_cache_semantics.py b/tests/unittest/test_doclib_cache_semantics.pyindex b1162135..2d095f01 100644--- a/tests/unittest/test_doclib_cache_semantics.py+++ b/tests/unittest/test_doclib_cache_semantics.py@@ -463,7 +463,7 @@ def test_parse_server_health_probe_disables_env_proxy_for_local_urls(monkeypatchchecker = ParseServerHealthCheck(None, interval_sec=1, probe_timeout_sec=2, startup_grace_sec=3, stop_timeout_sec=4)assert asyncio.run(checker._probe("http://127.0.0.1:16580")) == ProbeResult(healthy=True, tiers=["high"])- assert asyncio.run(checker._probe("https://staging.mineru.org.cn/api")) == ProbeResult(healthy=True, tiers=["high"])+ assert asyncio.run(checker._probe("https://mineru.net/api")) == ProbeResult(healthy=True, tiers=["high"])assert calls == [False, True]@@ -494,7 +494,7 @@ def test_parse_server_health_probe_maps_auth_error_and_passes_api_key(monkeypatcmonkeypatch.setattr("mineru.doclib.background.parse_server_health.httpx.AsyncClient", _AsyncClient)checker = ParseServerHealthCheck(None, interval_sec=1, probe_timeout_sec=2, startup_grace_sec=3, stop_timeout_sec=4)- result = asyncio.run(checker._probe("https://staging.mineru.org.cn/api", api_key="bad-key"))+ result = asyncio.run(checker._probe("https://mineru.net/api", api_key="bad-key"))assert result == ProbeResult(error_code="invalid_api_key", error_msg="Invalid or missing API key")assert seen_headers == [{"Authorization": "Bearer bad-key"}]diff --git a/tests/unittest/test_doclib_telemetry_core.py b/tests/unittest/test_doclib_telemetry_core.pyindex 46407d1c..0dcab7c5 100644--- a/tests/unittest/test_doclib_telemetry_core.py+++ b/tests/unittest/test_doclib_telemetry_core.py@@ -176,7 +176,7 @@ def test_telemetry_service_preview_returns_next_period_body(tmp_path) -> None:asyncio.run(_run())-def test_signed_headers_match_staging_api_contract() -> None:+def test_signed_headers_match_official_api_contract() -> None:body = b'{"api_version":"v2"}'headers = signed_headers(body, timestamp=1_700_000_000_000)diff --git a/tests/unittest/test_parser_api_contract.py b/tests/unittest/test_parser_api_contract.pyindex 10c34987..263f5c15 100644--- a/tests/unittest/test_parser_api_contract.py+++ b/tests/unittest/test_parser_api_contract.py@@ -332,9 +332,9 @@ def test_api_client_can_request_zip_for_image_cache(tmp_path: Path) -> None:assert payload["output_formats"] == ["zip"]-def test_api_client_uses_zip_for_staging_when_model_output_requested() -> None:+def test_api_client_uses_zip_for_official_api_when_model_output_requested() -> None:parser = MinerUApiParser(- api_url="https://staging.mineru.org.cn/api",+ api_url="https://mineru.net/api",tier="xhigh",include_model_output=True,)@@ -342,9 +342,9 @@ def test_api_client_uses_zip_for_staging_when_model_output_requested() -> None:assert parser._output_formats() == ["zip"]-def test_api_client_uses_zip_for_staging_when_image_cache_requested() -> None:+def test_api_client_uses_zip_for_official_api_when_image_cache_requested() -> None:parser = MinerUApiParser(- api_url="https://staging.mineru.org.cn/api",+ api_url="https://mineru.net/api",tier="xhigh",include_images=True,)@@ -369,8 +369,8 @@ def test_api_client_rejects_invalid_tier_names(tier: str) -> None:MinerUApiParser(api_url="http://localhost:8000", tier=tier) # type: ignore[arg-type]-def test_api_client_uses_middle_json_format_for_staging() -> None:- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="xhigh")+def test_api_client_uses_middle_json_format_for_official_api() -> None:+ parser = MinerUApiParser(api_url="https://mineru.net/api", tier="xhigh")assert parser._output_formats() == ["middle_json"]@@ -548,9 +548,9 @@ def test_api_client_downloads_model_output_from_zip(monkeypatch: pytest.MonkeyPaassert result._model_output == [[{"raw": "model"}]]-def test_api_client_reads_staging_layout_json_and_model_output_from_zip(monkeypatch: pytest.MonkeyPatch) -> None:+def test_api_client_reads_official_layout_json_and_model_output_from_zip(monkeypatch: pytest.MonkeyPatch) -> None:parser = MinerUApiParser(- api_url="https://staging.mineru.org.cn/api",+ api_url="https://mineru.net/api",tier="high",include_images=True,include_model_output=True,@@ -822,7 +822,7 @@ def test_api_client_include_images_rejects_unsafe_image_entries(monkeypatch: pytdef test_api_client_accepts_remote_pdf_info_middle_json(monkeypatch: pytest.MonkeyPatch) -> None:- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")+ parser = MinerUApiParser(api_url="https://mineru.net/api", tier="high")middle_json = {"_backend": "hybrid","_version_name": "remote",@@ -848,7 +848,7 @@ def test_api_client_accepts_remote_pdf_info_middle_json(monkeypatch: pytest.Monkdef test_async_api_client_accepts_remote_pdf_info_middle_json(monkeypatch: pytest.MonkeyPatch) -> None:- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")+ parser = MinerUApiParser(api_url="https://mineru.net/api", tier="high")middle_json = {"_backend": "hybrid","pdf_info": [{"page_idx": 0, "page_size": [100, 200]}],@@ -878,7 +878,7 @@ def test_async_api_client_accepts_remote_pdf_info_middle_json(monkeypatch: pytesdef test_api_client_rejects_legacy_json_output_file_key() -> None:- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")+ parser = MinerUApiParser(api_url="https://mineru.net/api", tier="high")with pytest.raises(api_client._V1APIError) as exc_info:_parse_result_from_job(@@ -896,7 +896,7 @@ def test_api_client_rejects_legacy_json_output_file_key() -> None:def test_api_client_rejects_output_reference_without_file_id() -> None:- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")+ parser = MinerUApiParser(api_url="https://mineru.net/api", tier="high")with pytest.raises(api_client._V1APIError) as exc_info:api_client._download_bytes(parser, {"url": "https://example.invalid/output.json", "bytes": 10})@@ -906,7 +906,7 @@ def test_api_client_rejects_output_reference_without_file_id() -> None:def test_async_api_client_rejects_output_reference_without_file_id() -> None:- parser = MinerUApiParser(api_url="https://staging.mineru.org.cn/api", tier="high")+ parser = MinerUApiParser(api_url="https://mineru.net/api", tier="high")async def _run() -> None:await api_client._async_download_bytes(parser, {"url": "https://example.invalid/output.json", "bytes": 10})@@ -1015,7 +1015,7 @@ def test_api_client_disables_env_proxy_for_local_network_urls() -> None:assert should_trust_env_for_url("http://localhost:8000") is Falseassert should_trust_env_for_url("http://127.0.0.1:8000") is Falseassert should_trust_env_for_url("http://192.168.1.20:8000/api") is False- assert should_trust_env_for_url("https://staging.mineru.org.cn/api") is True+ assert should_trust_env_for_url("https://mineru.net/api") is Truedef test_api_client_passes_trust_env_from_api_url(monkeypatch: pytest.MonkeyPatch) -> None: