puffinparse 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {puffinparse-0.1.3 → puffinparse-0.1.5}/Cargo.lock +5 -5
- {puffinparse-0.1.3 → puffinparse-0.1.5}/Cargo.toml +2 -2
- {puffinparse-0.1.3 → puffinparse-0.1.5}/PKG-INFO +30 -4
- {puffinparse-0.1.3 → puffinparse-0.1.5}/README.md +29 -3
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/http.rs +1 -1
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/model.rs +181 -16
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/pricing.json +20 -1
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/provider.rs +37 -1
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/anthropic.rs +136 -18
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/gemini.rs +52 -3
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/google_documentai.rs +15 -5
- puffinparse-0.1.5/crates/puffinparse-core/src/providers/local.rs +340 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/mod.rs +5 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/openai.rs +10 -3
- puffinparse-0.1.5/crates/puffinparse-core/src/providers/opendocrouter.rs +1332 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/paddleocr.rs +68 -5
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/tesseract.rs +11 -110
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/textract.rs +3 -0
- puffinparse-0.1.5/crates/puffinparse-core/src/providers/vllm.rs +843 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/README.md +1 -1
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/anthropic_messages_parse_auto_tool.json +36 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/opendocrouter_get_expanded.json +36 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/opendocrouter_parse_failed.json +21 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/opendocrouter_parse_layout.json +61 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/opendocrouter_parse_partial.json +45 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/paddleocr_vl_layout_parsing.json +59 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/vllm_dots_mocr_chat.json +26 -0
- puffinparse-0.1.5/crates/puffinparse-core/tests/fixtures/vllm_infinity_parser2_chat.json +27 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/pyproject.toml +1 -1
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/jobs.py +3 -2
- puffinparse-0.1.3/crates/puffinparse-core/src/providers/local.rs +0 -162
- {puffinparse-0.1.3 → puffinparse-0.1.5}/LICENSE +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/Cargo.toml +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/README.md +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/bench/tables.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/bench.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/compat/extend.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/compat/llamaparse.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/compat/mod.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/compat/reducto.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/compat/roundtrip.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/error.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/jobs.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/lib.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/pricing.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/azure.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/datalab.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/docling.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/extend.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/landingai.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/llamaparse.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/mathpix.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/mistral.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/reducto.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/unstructured.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/upstage.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/providers/vlm.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/router.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/testutil.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/types.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/src/util.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/benchmark_datasets.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/anthropic_messages_extract.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/anthropic_messages_parse.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/azure_invoice.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/azure_layout.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/azure_read.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/datalab_convert.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/docling_headings.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/docling_multipage.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/extend_extract_run.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/extend_parse_run.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/extend_parse_run_url.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/extend_parse_run_url_output.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/gemini_extract_invoice.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/gemini_parse_multipage.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/google_documentai_form.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/google_documentai_layout.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/google_documentai_ocr.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/landingai_extract.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/landingai_parse.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/llamaparse_extract_job.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/llamaparse_result_json.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/mathpix_pdf_lines.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/mathpix_text.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/mistral_annotation.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/mistral_ocr.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/mistral_ocr_blocks.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/openai_responses_extract.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/openai_responses_parse.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/paddleocr_layout_parsing.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/paddleocr_ocr.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/reducto_extract.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/reducto_extract_plain.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/reducto_parse.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/reducto_parse_url.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/reducto_parse_url_result.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/rules_text_sparse_note.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/tesseract_headings.tsv +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/textract_detect_text.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/textract_forms.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/textract_layout.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/textract_queries.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/unstructured_elements.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/fixtures/upstage_document_parse.json +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/live.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-core/tests/live_jobs.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-python/Cargo.toml +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/crates/puffinparse-python/src/lib.rs +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/__init__.py +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/_core.pyi +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/exceptions.py +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/main.py +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/py.typed +0 -0
- {puffinparse-0.1.3 → puffinparse-0.1.5}/python/puffinparse/types.py +0 -0
|
@@ -1395,7 +1395,7 @@ dependencies = [
|
|
|
1395
1395
|
|
|
1396
1396
|
[[package]]
|
|
1397
1397
|
name = "puffinparse-cli"
|
|
1398
|
-
version = "0.1.
|
|
1398
|
+
version = "0.1.5"
|
|
1399
1399
|
dependencies = [
|
|
1400
1400
|
"anyhow",
|
|
1401
1401
|
"chrono",
|
|
@@ -1415,7 +1415,7 @@ dependencies = [
|
|
|
1415
1415
|
|
|
1416
1416
|
[[package]]
|
|
1417
1417
|
name = "puffinparse-core"
|
|
1418
|
-
version = "0.1.
|
|
1418
|
+
version = "0.1.5"
|
|
1419
1419
|
dependencies = [
|
|
1420
1420
|
"async-trait",
|
|
1421
1421
|
"bytes",
|
|
@@ -1439,7 +1439,7 @@ dependencies = [
|
|
|
1439
1439
|
|
|
1440
1440
|
[[package]]
|
|
1441
1441
|
name = "puffinparse-node"
|
|
1442
|
-
version = "0.1.
|
|
1442
|
+
version = "0.1.5"
|
|
1443
1443
|
dependencies = [
|
|
1444
1444
|
"bytes",
|
|
1445
1445
|
"napi",
|
|
@@ -1453,7 +1453,7 @@ dependencies = [
|
|
|
1453
1453
|
|
|
1454
1454
|
[[package]]
|
|
1455
1455
|
name = "puffinparse-python"
|
|
1456
|
-
version = "0.1.
|
|
1456
|
+
version = "0.1.5"
|
|
1457
1457
|
dependencies = [
|
|
1458
1458
|
"bytes",
|
|
1459
1459
|
"puffinparse-core",
|
|
@@ -1468,7 +1468,7 @@ dependencies = [
|
|
|
1468
1468
|
|
|
1469
1469
|
[[package]]
|
|
1470
1470
|
name = "puffinparse-server"
|
|
1471
|
-
version = "0.1.
|
|
1471
|
+
version = "0.1.5"
|
|
1472
1472
|
dependencies = [
|
|
1473
1473
|
"axum",
|
|
1474
1474
|
"bytes",
|
|
@@ -3,7 +3,7 @@ resolver = "2"
|
|
|
3
3
|
members = ["crates/puffinparse-core", "crates/puffinparse-python"]
|
|
4
4
|
|
|
5
5
|
[workspace.package]
|
|
6
|
-
version = "0.1.
|
|
6
|
+
version = "0.1.5"
|
|
7
7
|
edition = "2021"
|
|
8
8
|
rust-version = "1.80"
|
|
9
9
|
license = "MIT"
|
|
@@ -15,7 +15,7 @@ keywords = ["ocr", "document-parsing", "pdf", "api", "benchmark"]
|
|
|
15
15
|
categories = ["api-bindings", "text-processing"]
|
|
16
16
|
|
|
17
17
|
[workspace.dependencies]
|
|
18
|
-
puffinparse-core = { path = "crates/puffinparse-core", version = "0.1.
|
|
18
|
+
puffinparse-core = { path = "crates/puffinparse-core", version = "0.1.5" }
|
|
19
19
|
reqwest = { version = "0.13", default-features = false, features = ["json", "multipart", "rustls", "stream", "gzip"] }
|
|
20
20
|
tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "time", "sync"] }
|
|
21
21
|
serde = { version = "1", features = ["derive"] }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: puffinparse
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Classifier: Development Status :: 3 - Alpha
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -61,7 +61,7 @@ Two things make switching real rather than aspirational. **Modes**: every call n
|
|
|
61
61
|
|
|
62
62
|
| | |
|
|
63
63
|
|---|---|
|
|
64
|
-
| **Providers (v0.1)** |
|
|
64
|
+
| **Providers (v0.1)** | 20 providers · 79 models · 3 modes. **Live-verified** against the real APIs: [Reducto](https://reducto.ai), [Extend](https://extend.ai), [LlamaParse](https://cloud.llamaindex.ai). **Verified locally**: the self-hosted Tesseract and Docling. **Docs-only** (implemented from the provider's API documentation and tested against fixture payloads, not yet run live): Mistral, Azure, Textract, Gemini, OpenAI, Anthropic, Mathpix, Datalab, Unstructured, Upstage, Landing AI, Google Document AI, OpenDocRouter and the self-hosted PaddleOCR and vLLM presets ([help verify them](https://github.com/ajinkyashejul/puffinparse/issues/10)). [Full table](#model-names) |
|
|
65
65
|
| **Modes** | `parse` (markdown + blocks), `ocr` (plain text + boxes), `extract` (JSON from a schema) |
|
|
66
66
|
| **Core** | Rust (`puffinparse-core`): `reqwest` + `tokio`, no vendor SDKs, `#![forbid(unsafe_code)]` |
|
|
67
67
|
| **SDKs** | Python 3.9+ (sync + async, fully typed) and Node.js / TypeScript ([`js/`](https://github.com/ajinkyashejul/puffinparse/blob/main/js/README.md)), both on the same Rust core |
|
|
@@ -216,8 +216,9 @@ result = puffinparse.retrieve(job) # Job (still pending) or ParseRe
|
|
|
216
216
|
result = puffinparse.handle_webhook(request.json(), model="reducto") # verify the signature first
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
Reducto, Extend and
|
|
220
|
-
where one exists (Extend only has workspace-level webhooks
|
|
219
|
+
Reducto, Extend, LlamaParse and OpenDocRouter support jobs; `webhook_url` maps to each provider's
|
|
220
|
+
per-job webhook where one exists (Extend only has workspace-level webhooks and OpenDocRouter has
|
|
221
|
+
none, so it is rejected there). See
|
|
221
222
|
[`docs/SPEC.md`](https://github.com/ajinkyashejul/puffinparse/blob/main/docs/SPEC.md) §15.
|
|
222
223
|
|
|
223
224
|
### TypeScript / Node.js
|
|
@@ -332,6 +333,8 @@ page per provider.
|
|
|
332
333
|
| `gemini/3.5-flash` | parse, ocr, extract | $0.00945 · $0.00945 · $0.00495 | Gemini 3.5 Flash: frontier Flash generation (GA 2026-05-19) |
|
|
333
334
|
| `gemini/3.5-flash-lite` | parse, ocr, extract | $0.00245 · $0.00245 · $0.0012 | Gemini 3.5 Flash-Lite: low-latency 3.x tier (GA 2026-07-21) |
|
|
334
335
|
| `gemini/3.8-flash` | parse, ocr, extract | $0.004125 · $0.004125 · $0.00225 | Gemini 3.8 Flash: newest Flash model (GA 2026-09-02, introductory pricing) |
|
|
336
|
+
| `gemini/3.8-flash-low` | parse, ocr, extract | $0.004125 · $0.004125 · $0.00225 | Gemini 3.8 Flash with thinkingConfig.thinkingLevel=low (cheaper, faster transcription) |
|
|
337
|
+
| `gemini/3-flash-preview` | parse, ocr, extract | $0.00315 · $0.00315 · $0.00165 | Gemini 3 Flash preview (gemini-3-flash-preview; PDF and image input) |
|
|
335
338
|
|
|
336
339
|
**OpenAI** · `OPENAI_API_KEY` · docs-only — Vision transcription through the Responses API. Per-page prices are estimates, as for Gemini.
|
|
337
340
|
|
|
@@ -341,6 +344,7 @@ page per provider.
|
|
|
341
344
|
| `openai/gpt-5.6-terra` | parse, ocr, extract | $0.0114 · $0.0114 · $0.0114 | OpenAI Responses API, gpt-5.6-terra (balanced capability/price) |
|
|
342
345
|
| `openai/gpt-5.6-sol` | parse, ocr, extract | $0.02 · $0.02 · $0.02 | OpenAI Responses API, gpt-5.6-sol (flagship GPT-5.6) |
|
|
343
346
|
| `openai/gpt-6-astra` | parse, ocr, extract | $0.05 · $0.05 · $0.05 | OpenAI Responses API, gpt-6-astra (most capable, most expensive) |
|
|
347
|
+
| `openai/gpt-6-luna` | parse, ocr, extract | $0.0005 · $0.0005 · $0.0005 | OpenAI Responses API, gpt-6-luna (cheapest GPT-6, image and PDF input) |
|
|
344
348
|
|
|
345
349
|
**Anthropic (Claude)** · `ANTHROPIC_API_KEY` · docs-only — Vision transcription through the Messages API. Per-page prices are estimates.
|
|
346
350
|
|
|
@@ -349,6 +353,8 @@ page per provider.
|
|
|
349
353
|
| `anthropic/claude-sonnet-5` | parse `*`, ocr `*`, extract `*` | $0.01 · $0.01 · $0.01 | Claude Messages API, claude-sonnet-5 (balanced vision transcription) |
|
|
350
354
|
| `anthropic/claude-haiku-4-5` | parse, ocr, extract | $0.005 · $0.005 · $0.005 | Claude Messages API, claude-haiku-4-5 (cheapest, 200K context) |
|
|
351
355
|
| `anthropic/claude-opus-5` | parse, ocr, extract | $0.025 · $0.025 · $0.025 | Claude Messages API, claude-opus-5 (highest accuracy) |
|
|
356
|
+
| `anthropic/claude-opus-5-5` | parse, ocr, extract | $0.02 · $0.02 · $0.02 | Claude Messages API, claude-opus-5-5 (current Opus; tool_choice auto, no forced tool) |
|
|
357
|
+
| `anthropic/claude-haiku-5-5` | parse, ocr, extract | $0.0005 · $0.0005 · $0.0005 | Claude Messages API, claude-haiku-5-5 (cheapest Claude, 1M context) |
|
|
352
358
|
|
|
353
359
|
**Mathpix** · `MATHPIX_APP_KEY` (+ `MATHPIX_APP_ID`) · docs-only — Maths-first OCR: Mathpix Markdown with LaTeX, line and word polygons.
|
|
354
360
|
|
|
@@ -395,13 +401,33 @@ page per provider.
|
|
|
395
401
|
| `google_documentai/form` | parse, ocr, extract `*` | $0.03 · $0.03 · $0.03 | Form Parser processor: paragraphs + tables, entities as extraction |
|
|
396
402
|
| `google_documentai/prebuilt` | parse, ocr, extract | $0.03 · $0.03 · $0.03 | Prebuilt or custom extractor (invoice, W2, ...): entities as extraction |
|
|
397
403
|
|
|
404
|
+
**OpenDocRouter** · `OPEN_DOC_ROUTER_API_KEY` · docs-only — LlamaIndex's hosted router: frontier VLMs and open OCR models behind one endpoint, billed per token at the providers' prices, per-page status and charge, layout boxes on request. Model ids keep the router's own `<vendor>/<model>` after the provider name. Prices here are the site's average charge per page (price version 2026-10-06); `cost_usd` is the actual `charge_usd`.
|
|
405
|
+
|
|
406
|
+
| Model | Modes | List price / page (parse · ocr · extract) | Notes |
|
|
407
|
+
|---|---|---|---|
|
|
408
|
+
| `opendocrouter/google/gemini-3.8-flash-low` | parse `*`, ocr `*` | $0.005908 · $0.005908 · — | Gemini 3.8 Flash (low thinking); the router's quickstart model |
|
|
409
|
+
| `opendocrouter/google/gemini-3-flash` | parse, ocr | $0.019667 · $0.019667 · — | Gemini 3 Flash |
|
|
410
|
+
| `opendocrouter/anthropic/claude-opus-5-5` | parse, ocr | $0.04882 · $0.04882 · — | Claude Opus 5.5 (frontier, most expensive) |
|
|
411
|
+
| `opendocrouter/anthropic/claude-haiku-5-5` | parse, ocr | $0.001225 · $0.001225 · — | Claude Haiku 5.5 |
|
|
412
|
+
| `opendocrouter/openai/gpt-5.6-terra` | parse, ocr | $0.019886 · $0.019886 · — | GPT-5.6 Terra |
|
|
413
|
+
| `opendocrouter/openai/gpt-6-luna` | parse, ocr | $0.000798 · $0.000798 · — | GPT-6 Luna (cheapest frontier model) |
|
|
414
|
+
| `opendocrouter/infly/infinity-parser2-flash` | parse, ocr | $0.004344 · $0.004344 · — | Infinity-Parser2-Flash (open model hosted by the router) |
|
|
415
|
+
| `opendocrouter/opendatalab/mineru2.5-pro` | parse, ocr | $0.000861 · $0.000861 · — | MinerU2.5-Pro (open model hosted by the router) |
|
|
416
|
+
| `opendocrouter/xingchen-agi/teleocr` | parse, ocr | $0.002702 · $0.002702 · — | TeleOCR (open model hosted by the router) |
|
|
417
|
+
| `opendocrouter/rednote-hilab/dots.mocr` | parse, ocr | $0.00397 · $0.00397 · — | dots.mocr (open model hosted by the router) |
|
|
418
|
+
| `opendocrouter/paddlepaddle/paddleocr-vl-1.6` | parse, ocr | $0.002111 · $0.002111 · — | PaddleOCR-VL-1.6 (open model hosted by the router) |
|
|
419
|
+
|
|
398
420
|
**Self-hosted engines** · no key · $0/page — out-of-process: a local binary or a server you run. Tesseract and Docling are verified locally; PaddleOCR is docs-only.
|
|
421
|
+
**Self-hosted engines** · no key · $0/page — out-of-process: a local binary or a server you run. Tesseract and Docling are verified locally; PaddleOCR and vLLM are docs-only.
|
|
399
422
|
|
|
400
423
|
| Model | Modes | List price / page (parse · ocr · extract) | Notes |
|
|
401
424
|
|---|---|---|---|
|
|
402
425
|
| `tesseract/default` | ocr `*` (native), parse `*` | $0 · $0 · — | local `tesseract` binary (`TESSERACT_CMD`), PDFs via `pdftoppm`; word/line boxes + confidences, no layout model; verified locally |
|
|
403
426
|
| `docling/default` | parse `*`, ocr `*` | $0 · $0 · — | your docling-serve (`DOCLING_BASE_URL`): layout, tables, OCR; verified locally |
|
|
404
427
|
| `paddleocr/default` | ocr `*` (native), parse `*` (PP-StructureV3) | $0 · $0 · — | your PaddleOCR serving (`PADDLEOCR_BASE_URL`); docs-only |
|
|
428
|
+
| `paddleocr/vl` | parse, ocr | $0 · $0 · — | your PaddleOCR-VL pipeline serving (`PADDLEOCR_VL_BASE_URL`; PaddleOCR-VL-1.6 by default): layout + 0.9B VLM; docs-only |
|
|
429
|
+
| `vllm/infinity-parser2-flash` | parse `*`, ocr `*` | $0 · $0 · — | `infly/Infinity-Parser2-Flash` on your `vllm serve` (`VLLM_BASE_URL`): page images, layout blocks with boxes; docs-only |
|
|
430
|
+
| `vllm/dots.mocr` | parse, ocr | $0 · $0 · — | `rednote-hilab/dots.mocr` on your `vllm serve` (`VLLM_BASE_URL`): page images, layout blocks with boxes; docs-only |
|
|
405
431
|
|
|
406
432
|
### Keep your Reducto / Extend / LlamaParse code
|
|
407
433
|
|
|
@@ -27,7 +27,7 @@ Two things make switching real rather than aspirational. **Modes**: every call n
|
|
|
27
27
|
|
|
28
28
|
| | |
|
|
29
29
|
|---|---|
|
|
30
|
-
| **Providers (v0.1)** |
|
|
30
|
+
| **Providers (v0.1)** | 20 providers · 79 models · 3 modes. **Live-verified** against the real APIs: [Reducto](https://reducto.ai), [Extend](https://extend.ai), [LlamaParse](https://cloud.llamaindex.ai). **Verified locally**: the self-hosted Tesseract and Docling. **Docs-only** (implemented from the provider's API documentation and tested against fixture payloads, not yet run live): Mistral, Azure, Textract, Gemini, OpenAI, Anthropic, Mathpix, Datalab, Unstructured, Upstage, Landing AI, Google Document AI, OpenDocRouter and the self-hosted PaddleOCR and vLLM presets ([help verify them](https://github.com/ajinkyashejul/puffinparse/issues/10)). [Full table](#model-names) |
|
|
31
31
|
| **Modes** | `parse` (markdown + blocks), `ocr` (plain text + boxes), `extract` (JSON from a schema) |
|
|
32
32
|
| **Core** | Rust (`puffinparse-core`): `reqwest` + `tokio`, no vendor SDKs, `#![forbid(unsafe_code)]` |
|
|
33
33
|
| **SDKs** | Python 3.9+ (sync + async, fully typed) and Node.js / TypeScript ([`js/`](https://github.com/ajinkyashejul/puffinparse/blob/main/js/README.md)), both on the same Rust core |
|
|
@@ -182,8 +182,9 @@ result = puffinparse.retrieve(job) # Job (still pending) or ParseRe
|
|
|
182
182
|
result = puffinparse.handle_webhook(request.json(), model="reducto") # verify the signature first
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
Reducto, Extend and
|
|
186
|
-
where one exists (Extend only has workspace-level webhooks
|
|
185
|
+
Reducto, Extend, LlamaParse and OpenDocRouter support jobs; `webhook_url` maps to each provider's
|
|
186
|
+
per-job webhook where one exists (Extend only has workspace-level webhooks and OpenDocRouter has
|
|
187
|
+
none, so it is rejected there). See
|
|
187
188
|
[`docs/SPEC.md`](https://github.com/ajinkyashejul/puffinparse/blob/main/docs/SPEC.md) §15.
|
|
188
189
|
|
|
189
190
|
### TypeScript / Node.js
|
|
@@ -298,6 +299,8 @@ page per provider.
|
|
|
298
299
|
| `gemini/3.5-flash` | parse, ocr, extract | $0.00945 · $0.00945 · $0.00495 | Gemini 3.5 Flash: frontier Flash generation (GA 2026-05-19) |
|
|
299
300
|
| `gemini/3.5-flash-lite` | parse, ocr, extract | $0.00245 · $0.00245 · $0.0012 | Gemini 3.5 Flash-Lite: low-latency 3.x tier (GA 2026-07-21) |
|
|
300
301
|
| `gemini/3.8-flash` | parse, ocr, extract | $0.004125 · $0.004125 · $0.00225 | Gemini 3.8 Flash: newest Flash model (GA 2026-09-02, introductory pricing) |
|
|
302
|
+
| `gemini/3.8-flash-low` | parse, ocr, extract | $0.004125 · $0.004125 · $0.00225 | Gemini 3.8 Flash with thinkingConfig.thinkingLevel=low (cheaper, faster transcription) |
|
|
303
|
+
| `gemini/3-flash-preview` | parse, ocr, extract | $0.00315 · $0.00315 · $0.00165 | Gemini 3 Flash preview (gemini-3-flash-preview; PDF and image input) |
|
|
301
304
|
|
|
302
305
|
**OpenAI** · `OPENAI_API_KEY` · docs-only — Vision transcription through the Responses API. Per-page prices are estimates, as for Gemini.
|
|
303
306
|
|
|
@@ -307,6 +310,7 @@ page per provider.
|
|
|
307
310
|
| `openai/gpt-5.6-terra` | parse, ocr, extract | $0.0114 · $0.0114 · $0.0114 | OpenAI Responses API, gpt-5.6-terra (balanced capability/price) |
|
|
308
311
|
| `openai/gpt-5.6-sol` | parse, ocr, extract | $0.02 · $0.02 · $0.02 | OpenAI Responses API, gpt-5.6-sol (flagship GPT-5.6) |
|
|
309
312
|
| `openai/gpt-6-astra` | parse, ocr, extract | $0.05 · $0.05 · $0.05 | OpenAI Responses API, gpt-6-astra (most capable, most expensive) |
|
|
313
|
+
| `openai/gpt-6-luna` | parse, ocr, extract | $0.0005 · $0.0005 · $0.0005 | OpenAI Responses API, gpt-6-luna (cheapest GPT-6, image and PDF input) |
|
|
310
314
|
|
|
311
315
|
**Anthropic (Claude)** · `ANTHROPIC_API_KEY` · docs-only — Vision transcription through the Messages API. Per-page prices are estimates.
|
|
312
316
|
|
|
@@ -315,6 +319,8 @@ page per provider.
|
|
|
315
319
|
| `anthropic/claude-sonnet-5` | parse `*`, ocr `*`, extract `*` | $0.01 · $0.01 · $0.01 | Claude Messages API, claude-sonnet-5 (balanced vision transcription) |
|
|
316
320
|
| `anthropic/claude-haiku-4-5` | parse, ocr, extract | $0.005 · $0.005 · $0.005 | Claude Messages API, claude-haiku-4-5 (cheapest, 200K context) |
|
|
317
321
|
| `anthropic/claude-opus-5` | parse, ocr, extract | $0.025 · $0.025 · $0.025 | Claude Messages API, claude-opus-5 (highest accuracy) |
|
|
322
|
+
| `anthropic/claude-opus-5-5` | parse, ocr, extract | $0.02 · $0.02 · $0.02 | Claude Messages API, claude-opus-5-5 (current Opus; tool_choice auto, no forced tool) |
|
|
323
|
+
| `anthropic/claude-haiku-5-5` | parse, ocr, extract | $0.0005 · $0.0005 · $0.0005 | Claude Messages API, claude-haiku-5-5 (cheapest Claude, 1M context) |
|
|
318
324
|
|
|
319
325
|
**Mathpix** · `MATHPIX_APP_KEY` (+ `MATHPIX_APP_ID`) · docs-only — Maths-first OCR: Mathpix Markdown with LaTeX, line and word polygons.
|
|
320
326
|
|
|
@@ -361,13 +367,33 @@ page per provider.
|
|
|
361
367
|
| `google_documentai/form` | parse, ocr, extract `*` | $0.03 · $0.03 · $0.03 | Form Parser processor: paragraphs + tables, entities as extraction |
|
|
362
368
|
| `google_documentai/prebuilt` | parse, ocr, extract | $0.03 · $0.03 · $0.03 | Prebuilt or custom extractor (invoice, W2, ...): entities as extraction |
|
|
363
369
|
|
|
370
|
+
**OpenDocRouter** · `OPEN_DOC_ROUTER_API_KEY` · docs-only — LlamaIndex's hosted router: frontier VLMs and open OCR models behind one endpoint, billed per token at the providers' prices, per-page status and charge, layout boxes on request. Model ids keep the router's own `<vendor>/<model>` after the provider name. Prices here are the site's average charge per page (price version 2026-10-06); `cost_usd` is the actual `charge_usd`.
|
|
371
|
+
|
|
372
|
+
| Model | Modes | List price / page (parse · ocr · extract) | Notes |
|
|
373
|
+
|---|---|---|---|
|
|
374
|
+
| `opendocrouter/google/gemini-3.8-flash-low` | parse `*`, ocr `*` | $0.005908 · $0.005908 · — | Gemini 3.8 Flash (low thinking); the router's quickstart model |
|
|
375
|
+
| `opendocrouter/google/gemini-3-flash` | parse, ocr | $0.019667 · $0.019667 · — | Gemini 3 Flash |
|
|
376
|
+
| `opendocrouter/anthropic/claude-opus-5-5` | parse, ocr | $0.04882 · $0.04882 · — | Claude Opus 5.5 (frontier, most expensive) |
|
|
377
|
+
| `opendocrouter/anthropic/claude-haiku-5-5` | parse, ocr | $0.001225 · $0.001225 · — | Claude Haiku 5.5 |
|
|
378
|
+
| `opendocrouter/openai/gpt-5.6-terra` | parse, ocr | $0.019886 · $0.019886 · — | GPT-5.6 Terra |
|
|
379
|
+
| `opendocrouter/openai/gpt-6-luna` | parse, ocr | $0.000798 · $0.000798 · — | GPT-6 Luna (cheapest frontier model) |
|
|
380
|
+
| `opendocrouter/infly/infinity-parser2-flash` | parse, ocr | $0.004344 · $0.004344 · — | Infinity-Parser2-Flash (open model hosted by the router) |
|
|
381
|
+
| `opendocrouter/opendatalab/mineru2.5-pro` | parse, ocr | $0.000861 · $0.000861 · — | MinerU2.5-Pro (open model hosted by the router) |
|
|
382
|
+
| `opendocrouter/xingchen-agi/teleocr` | parse, ocr | $0.002702 · $0.002702 · — | TeleOCR (open model hosted by the router) |
|
|
383
|
+
| `opendocrouter/rednote-hilab/dots.mocr` | parse, ocr | $0.00397 · $0.00397 · — | dots.mocr (open model hosted by the router) |
|
|
384
|
+
| `opendocrouter/paddlepaddle/paddleocr-vl-1.6` | parse, ocr | $0.002111 · $0.002111 · — | PaddleOCR-VL-1.6 (open model hosted by the router) |
|
|
385
|
+
|
|
364
386
|
**Self-hosted engines** · no key · $0/page — out-of-process: a local binary or a server you run. Tesseract and Docling are verified locally; PaddleOCR is docs-only.
|
|
387
|
+
**Self-hosted engines** · no key · $0/page — out-of-process: a local binary or a server you run. Tesseract and Docling are verified locally; PaddleOCR and vLLM are docs-only.
|
|
365
388
|
|
|
366
389
|
| Model | Modes | List price / page (parse · ocr · extract) | Notes |
|
|
367
390
|
|---|---|---|---|
|
|
368
391
|
| `tesseract/default` | ocr `*` (native), parse `*` | $0 · $0 · — | local `tesseract` binary (`TESSERACT_CMD`), PDFs via `pdftoppm`; word/line boxes + confidences, no layout model; verified locally |
|
|
369
392
|
| `docling/default` | parse `*`, ocr `*` | $0 · $0 · — | your docling-serve (`DOCLING_BASE_URL`): layout, tables, OCR; verified locally |
|
|
370
393
|
| `paddleocr/default` | ocr `*` (native), parse `*` (PP-StructureV3) | $0 · $0 · — | your PaddleOCR serving (`PADDLEOCR_BASE_URL`); docs-only |
|
|
394
|
+
| `paddleocr/vl` | parse, ocr | $0 · $0 · — | your PaddleOCR-VL pipeline serving (`PADDLEOCR_VL_BASE_URL`; PaddleOCR-VL-1.6 by default): layout + 0.9B VLM; docs-only |
|
|
395
|
+
| `vllm/infinity-parser2-flash` | parse `*`, ocr `*` | $0 · $0 · — | `infly/Infinity-Parser2-Flash` on your `vllm serve` (`VLLM_BASE_URL`): page images, layout blocks with boxes; docs-only |
|
|
396
|
+
| `vllm/dots.mocr` | parse, ocr | $0 · $0 · — | `rednote-hilab/dots.mocr` on your `vllm serve` (`VLLM_BASE_URL`): page images, layout blocks with boxes; docs-only |
|
|
371
397
|
|
|
372
398
|
### Keep your Reducto / Extend / LlamaParse code
|
|
373
399
|
|
|
@@ -106,7 +106,7 @@ where
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
fn is_transient(e: &Error) -> bool {
|
|
109
|
+
pub(crate) fn is_transient(e: &Error) -> bool {
|
|
110
110
|
matches!(e.kind, ErrorKind::RateLimit | ErrorKind::Network)
|
|
111
111
|
|| (e.kind == ErrorKind::Provider && matches!(e.status_code, Some(500 | 502 | 503 | 504)))
|
|
112
112
|
}
|
|
@@ -43,7 +43,7 @@ pub struct ProviderInfo {
|
|
|
43
43
|
/// Providers that run on the caller's machine or their own server: no API key is required and
|
|
44
44
|
/// the per-page price is 0. Kept as a list (rather than a field on every entry) so adding one
|
|
45
45
|
/// does not touch the hosted providers' registry entries.
|
|
46
|
-
pub const SELF_HOSTED: &[&str] = &["tesseract", "docling", "paddleocr"];
|
|
46
|
+
pub const SELF_HOSTED: &[&str] = &["tesseract", "docling", "paddleocr", "vllm"];
|
|
47
47
|
|
|
48
48
|
impl ProviderInfo {
|
|
49
49
|
/// `true` for local / self-hosted engines (see [`SELF_HOSTED`]).
|
|
@@ -385,6 +385,20 @@ pub const PROVIDERS: &[ProviderInfo] = &[
|
|
|
385
385
|
default: false,
|
|
386
386
|
modes: Mode::ALL,
|
|
387
387
|
},
|
|
388
|
+
ModelInfo {
|
|
389
|
+
provider: "gemini",
|
|
390
|
+
model: "3.8-flash-low",
|
|
391
|
+
description: "Gemini 3.8 Flash with thinkingConfig.thinkingLevel=low (cheaper, faster transcription)",
|
|
392
|
+
default: false,
|
|
393
|
+
modes: Mode::ALL,
|
|
394
|
+
},
|
|
395
|
+
ModelInfo {
|
|
396
|
+
provider: "gemini",
|
|
397
|
+
model: "3-flash-preview",
|
|
398
|
+
description: "Gemini 3 Flash preview (gemini-3-flash-preview; PDF and image input)",
|
|
399
|
+
default: false,
|
|
400
|
+
modes: Mode::ALL,
|
|
401
|
+
},
|
|
388
402
|
],
|
|
389
403
|
},
|
|
390
404
|
ProviderInfo {
|
|
@@ -422,6 +436,13 @@ pub const PROVIDERS: &[ProviderInfo] = &[
|
|
|
422
436
|
default: false,
|
|
423
437
|
modes: Mode::ALL,
|
|
424
438
|
},
|
|
439
|
+
ModelInfo {
|
|
440
|
+
provider: "openai",
|
|
441
|
+
model: "gpt-6-luna",
|
|
442
|
+
description: "OpenAI Responses API, gpt-6-luna (cheapest GPT-6, image and PDF input)",
|
|
443
|
+
default: false,
|
|
444
|
+
modes: Mode::ALL,
|
|
445
|
+
},
|
|
425
446
|
],
|
|
426
447
|
},
|
|
427
448
|
ProviderInfo {
|
|
@@ -452,6 +473,20 @@ pub const PROVIDERS: &[ProviderInfo] = &[
|
|
|
452
473
|
default: false,
|
|
453
474
|
modes: Mode::ALL,
|
|
454
475
|
},
|
|
476
|
+
ModelInfo {
|
|
477
|
+
provider: "anthropic",
|
|
478
|
+
model: "claude-opus-5-5",
|
|
479
|
+
description: "Claude Messages API, claude-opus-5-5 (current Opus; tool_choice auto, no forced tool)",
|
|
480
|
+
default: false,
|
|
481
|
+
modes: Mode::ALL,
|
|
482
|
+
},
|
|
483
|
+
ModelInfo {
|
|
484
|
+
provider: "anthropic",
|
|
485
|
+
model: "claude-haiku-5-5",
|
|
486
|
+
description: "Claude Messages API, claude-haiku-5-5 (cheapest Claude, 1M context)",
|
|
487
|
+
default: false,
|
|
488
|
+
modes: Mode::ALL,
|
|
489
|
+
},
|
|
455
490
|
],
|
|
456
491
|
},
|
|
457
492
|
ProviderInfo {
|
|
@@ -613,6 +648,93 @@ pub const PROVIDERS: &[ProviderInfo] = &[
|
|
|
613
648
|
},
|
|
614
649
|
],
|
|
615
650
|
},
|
|
651
|
+
ProviderInfo {
|
|
652
|
+
name: "opendocrouter",
|
|
653
|
+
display_name: "OpenDocRouter",
|
|
654
|
+
env_var: "OPEN_DOC_ROUTER_API_KEY",
|
|
655
|
+
base_url: "https://www.opendocrouter.ai",
|
|
656
|
+
docs: "https://www.opendocrouter.ai/docs",
|
|
657
|
+
// Model ids are the router's own vendor-qualified ids: `opendocrouter/<vendor>/<model>`.
|
|
658
|
+
models: &[
|
|
659
|
+
ModelInfo {
|
|
660
|
+
provider: "opendocrouter",
|
|
661
|
+
model: "google/gemini-3.8-flash-low",
|
|
662
|
+
description: "Gemini 3.8 Flash (low thinking) via OpenDocRouter; the router's quickstart model",
|
|
663
|
+
default: true,
|
|
664
|
+
modes: PARSE_OCR,
|
|
665
|
+
},
|
|
666
|
+
ModelInfo {
|
|
667
|
+
provider: "opendocrouter",
|
|
668
|
+
model: "google/gemini-3-flash",
|
|
669
|
+
description: "Gemini 3 Flash via OpenDocRouter",
|
|
670
|
+
default: false,
|
|
671
|
+
modes: PARSE_OCR,
|
|
672
|
+
},
|
|
673
|
+
ModelInfo {
|
|
674
|
+
provider: "opendocrouter",
|
|
675
|
+
model: "anthropic/claude-opus-5-5",
|
|
676
|
+
description: "Claude Opus 5.5 via OpenDocRouter (frontier, most expensive)",
|
|
677
|
+
default: false,
|
|
678
|
+
modes: PARSE_OCR,
|
|
679
|
+
},
|
|
680
|
+
ModelInfo {
|
|
681
|
+
provider: "opendocrouter",
|
|
682
|
+
model: "anthropic/claude-haiku-5-5",
|
|
683
|
+
description: "Claude Haiku 5.5 via OpenDocRouter",
|
|
684
|
+
default: false,
|
|
685
|
+
modes: PARSE_OCR,
|
|
686
|
+
},
|
|
687
|
+
ModelInfo {
|
|
688
|
+
provider: "opendocrouter",
|
|
689
|
+
model: "openai/gpt-5.6-terra",
|
|
690
|
+
description: "GPT-5.6 Terra via OpenDocRouter",
|
|
691
|
+
default: false,
|
|
692
|
+
modes: PARSE_OCR,
|
|
693
|
+
},
|
|
694
|
+
ModelInfo {
|
|
695
|
+
provider: "opendocrouter",
|
|
696
|
+
model: "openai/gpt-6-luna",
|
|
697
|
+
description: "GPT-6 Luna via OpenDocRouter (cheapest frontier model)",
|
|
698
|
+
default: false,
|
|
699
|
+
modes: PARSE_OCR,
|
|
700
|
+
},
|
|
701
|
+
ModelInfo {
|
|
702
|
+
provider: "opendocrouter",
|
|
703
|
+
model: "infly/infinity-parser2-flash",
|
|
704
|
+
description: "Infinity-Parser2-Flash (open OCR model hosted by OpenDocRouter)",
|
|
705
|
+
default: false,
|
|
706
|
+
modes: PARSE_OCR,
|
|
707
|
+
},
|
|
708
|
+
ModelInfo {
|
|
709
|
+
provider: "opendocrouter",
|
|
710
|
+
model: "opendatalab/mineru2.5-pro",
|
|
711
|
+
description: "MinerU2.5-Pro (open OCR model hosted by OpenDocRouter)",
|
|
712
|
+
default: false,
|
|
713
|
+
modes: PARSE_OCR,
|
|
714
|
+
},
|
|
715
|
+
ModelInfo {
|
|
716
|
+
provider: "opendocrouter",
|
|
717
|
+
model: "xingchen-agi/teleocr",
|
|
718
|
+
description: "TeleOCR (open OCR model hosted by OpenDocRouter)",
|
|
719
|
+
default: false,
|
|
720
|
+
modes: PARSE_OCR,
|
|
721
|
+
},
|
|
722
|
+
ModelInfo {
|
|
723
|
+
provider: "opendocrouter",
|
|
724
|
+
model: "rednote-hilab/dots.mocr",
|
|
725
|
+
description: "dots.mocr (open OCR model hosted by OpenDocRouter)",
|
|
726
|
+
default: false,
|
|
727
|
+
modes: PARSE_OCR,
|
|
728
|
+
},
|
|
729
|
+
ModelInfo {
|
|
730
|
+
provider: "opendocrouter",
|
|
731
|
+
model: "paddlepaddle/paddleocr-vl-1.6",
|
|
732
|
+
description: "PaddleOCR-VL-1.6 (open OCR model hosted by OpenDocRouter)",
|
|
733
|
+
default: false,
|
|
734
|
+
modes: PARSE_OCR,
|
|
735
|
+
},
|
|
736
|
+
],
|
|
737
|
+
},
|
|
616
738
|
ProviderInfo {
|
|
617
739
|
name: "tesseract",
|
|
618
740
|
display_name: "Tesseract (local)",
|
|
@@ -646,17 +768,51 @@ pub const PROVIDERS: &[ProviderInfo] = &[
|
|
|
646
768
|
ProviderInfo {
|
|
647
769
|
name: "paddleocr",
|
|
648
770
|
display_name: "PaddleOCR (PaddleX serving, self-hosted)",
|
|
649
|
-
// No key. PADDLEOCR_BASE_URL (OCR pipeline), PADDLEOCR_PARSE_BASE_URL (PP-StructureV3)
|
|
771
|
+
// No key. PADDLEOCR_BASE_URL (OCR pipeline), PADDLEOCR_PARSE_BASE_URL (PP-StructureV3),
|
|
772
|
+
// PADDLEOCR_VL_BASE_URL (PaddleOCR-VL pipeline).
|
|
650
773
|
env_var: "",
|
|
651
774
|
base_url: "http://localhost:8080",
|
|
652
775
|
docs: "https://www.paddleocr.ai/latest/en/version3.x/deployment/serving.html",
|
|
653
|
-
models: &[
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
776
|
+
models: &[
|
|
777
|
+
ModelInfo {
|
|
778
|
+
provider: "paddleocr",
|
|
779
|
+
model: "default",
|
|
780
|
+
description: "PaddleOCR 3 serving: OCR pipeline for ocr, PP-StructureV3 for parse; free, self-hosted",
|
|
781
|
+
default: true,
|
|
782
|
+
modes: &[Mode::Ocr, Mode::Parse],
|
|
783
|
+
},
|
|
784
|
+
ModelInfo {
|
|
785
|
+
provider: "paddleocr",
|
|
786
|
+
model: "vl",
|
|
787
|
+
description: "PaddleOCR-VL pipeline serving (PaddleOCR-VL-1.6 by default): layout + 0.9B VLM; free, self-hosted",
|
|
788
|
+
default: false,
|
|
789
|
+
modes: PARSE_OCR,
|
|
790
|
+
},
|
|
791
|
+
],
|
|
792
|
+
},
|
|
793
|
+
ProviderInfo {
|
|
794
|
+
name: "vllm",
|
|
795
|
+
display_name: "vLLM (OpenAI-compatible server, self-hosted)",
|
|
796
|
+
// Optional: only when the server runs with `--api-key`. Base URL: VLLM_BASE_URL.
|
|
797
|
+
env_var: "VLLM_API_KEY",
|
|
798
|
+
base_url: "http://localhost:8000",
|
|
799
|
+
docs: "https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html",
|
|
800
|
+
models: &[
|
|
801
|
+
ModelInfo {
|
|
802
|
+
provider: "vllm",
|
|
803
|
+
model: "infinity-parser2-flash",
|
|
804
|
+
description: "infly/Infinity-Parser2-Flash on your vLLM: page images, doc2json layout with boxes; free, self-hosted",
|
|
805
|
+
default: true,
|
|
806
|
+
modes: PARSE_OCR,
|
|
807
|
+
},
|
|
808
|
+
ModelInfo {
|
|
809
|
+
provider: "vllm",
|
|
810
|
+
model: "dots.mocr",
|
|
811
|
+
description: "rednote-hilab/dots.mocr on your vLLM: page images, layout JSON with boxes; free, self-hosted",
|
|
812
|
+
default: false,
|
|
813
|
+
modes: PARSE_OCR,
|
|
814
|
+
},
|
|
815
|
+
],
|
|
660
816
|
},
|
|
661
817
|
];
|
|
662
818
|
|
|
@@ -697,6 +853,8 @@ impl ModelRef {
|
|
|
697
853
|
"landing" | "landing_ai" | "landing-ai" | "ade" => "landingai".to_string(),
|
|
698
854
|
"paddle" | "paddle_ocr" | "paddle-ocr" | "paddlex" => "paddleocr".to_string(),
|
|
699
855
|
"docling_serve" | "docling-serve" => "docling".to_string(),
|
|
856
|
+
"odr" | "open_doc_router" | "open-doc-router" => "opendocrouter".to_string(),
|
|
857
|
+
"vllm-server" | "vllm_server" | "openai-compatible" | "openai_compatible" => "vllm".to_string(),
|
|
700
858
|
other => other.to_string(),
|
|
701
859
|
};
|
|
702
860
|
let info = provider_info(&prov).ok_or_else(|| {
|
|
@@ -793,12 +951,10 @@ mod tests {
|
|
|
793
951
|
assert_eq!(ModelRef::parse_for("azure", Mode::Ocr).unwrap().qualified(), "azure/read");
|
|
794
952
|
assert_eq!(ModelRef::parse_for("azure", Mode::Parse).unwrap().qualified(), "azure/layout");
|
|
795
953
|
assert_eq!(ModelRef::parse_for("azure", Mode::Extract).unwrap().qualified(), "azure/invoice");
|
|
796
|
-
assert!(list_models_for(Mode::Extract).iter().all(|m|
|
|
797
|
-
m.
|
|
798
|
-
|
|
799
|
-
)
|
|
800
|
-
.unwrap()
|
|
801
|
-
.supports(Mode::Extract)));
|
|
954
|
+
assert!(list_models_for(Mode::Extract).iter().all(|m| {
|
|
955
|
+
let (provider, model) = m.split_once('/').unwrap();
|
|
956
|
+
model_info(provider, model).unwrap().supports(Mode::Extract)
|
|
957
|
+
}));
|
|
802
958
|
assert!(list_models_for(Mode::Extract).contains(&"mistral/ocr-latest".to_string()));
|
|
803
959
|
}
|
|
804
960
|
|
|
@@ -806,7 +962,13 @@ mod tests {
|
|
|
806
962
|
fn lists_models() {
|
|
807
963
|
let m = list_models();
|
|
808
964
|
assert!(m.contains(&"extend/parse_performance".to_string()));
|
|
809
|
-
|
|
965
|
+
// Model ids may themselves contain '/': only the first one separates the provider.
|
|
966
|
+
assert!(m.contains(&"opendocrouter/google/gemini-3-flash".to_string()));
|
|
967
|
+
assert_eq!(
|
|
968
|
+
model_info("opendocrouter", "google/gemini-3-flash").unwrap().qualified(),
|
|
969
|
+
"opendocrouter/google/gemini-3-flash"
|
|
970
|
+
);
|
|
971
|
+
assert_eq!(m.len(), 79);
|
|
810
972
|
}
|
|
811
973
|
|
|
812
974
|
#[test]
|
|
@@ -819,6 +981,9 @@ mod tests {
|
|
|
819
981
|
assert!(provider_info("reducto").unwrap().key_required());
|
|
820
982
|
assert_eq!(ModelRef::parse_for("tesseract", Mode::Ocr).unwrap().qualified(), "tesseract/default");
|
|
821
983
|
assert_eq!(ModelRef::parse_for("paddle", Mode::Parse).unwrap().qualified(), "paddleocr/default");
|
|
984
|
+
assert_eq!(ModelRef::parse_for("paddleocr/vl", Mode::Ocr).unwrap().qualified(), "paddleocr/vl");
|
|
985
|
+
assert_eq!(ModelRef::parse_for("vllm", Mode::Parse).unwrap().qualified(), "vllm/infinity-parser2-flash");
|
|
986
|
+
assert_eq!(ModelRef::parse("vllm/Dots.MOCR").unwrap().qualified(), "vllm/dots.mocr");
|
|
822
987
|
let v = serde_json::to_value(provider_info("docling").unwrap()).unwrap();
|
|
823
988
|
assert_eq!(v["self_hosted"], true);
|
|
824
989
|
assert_eq!(v["models"][0]["model"], "default");
|
|
@@ -31,13 +31,18 @@
|
|
|
31
31
|
"gemini/3.5-flash": { "parse": 0.00945, "ocr": 0.00945, "extract": 0.00495, "source": "https://ai.google.dev/gemini-api/docs/pricing ($1.50/$9.00 per 1M; per-page ESTIMATE = 1500 input + 800 output tokens, extract 300 output)", "updated": "2026-09-11" },
|
|
32
32
|
"gemini/3.5-flash-lite": { "parse": 0.00245, "ocr": 0.00245, "extract": 0.0012, "source": "https://ai.google.dev/gemini-api/docs/pricing ($0.30/$2.50 per 1M; per-page ESTIMATE = 1500 input + 800 output tokens, extract 300 output)", "updated": "2026-09-11" },
|
|
33
33
|
"gemini/3.8-flash": { "parse": 0.004125, "ocr": 0.004125, "extract": 0.00225, "source": "https://ai.google.dev/gemini-api/docs/pricing ($0.75/$3.75 per 1M introductory through 2026-12-31; per-page ESTIMATE = 1500 input + 800 output tokens, extract 300 output)", "updated": "2026-09-11" },
|
|
34
|
+
"gemini/3.8-flash-low": { "parse": 0.004125, "ocr": 0.004125, "extract": 0.00225, "source": "https://ai.google.dev/gemini-api/docs/pricing (gemini-3.8-flash with thinkingLevel=low; same $0.75/$3.75 per 1M introductory through 2026-12-31; per-page ESTIMATE = 1500 input + 800 output tokens, extract 300 output; low thinking lowers the real output side)", "updated": "2026-10-08" },
|
|
35
|
+
"gemini/3-flash-preview": { "parse": 0.00315, "ocr": 0.00315, "extract": 0.00165, "source": "https://ai.google.dev/gemini-api/docs/pricing (gemini-3-flash-preview $0.50/$3.00 per 1M text/image in, out incl. thinking; per-page ESTIMATE = 1500 input + 800 output tokens, extract 300 output)", "updated": "2026-10-08" },
|
|
34
36
|
"openai/gpt-5.6-luna": { "parse": 0.00114, "ocr": 0.00114, "extract": 0.00114, "source": "https://developers.openai.com/api/docs/pricing (ESTIMATE from $0.20/$1.20 per 1M in/out tokens x ~1500 input + ~700 output tokens/page; real cost from usage)", "updated": "2026-09-11" },
|
|
35
37
|
"openai/gpt-5.6-terra": { "parse": 0.0114, "ocr": 0.0114, "extract": 0.0114, "source": "https://developers.openai.com/api/docs/pricing (ESTIMATE from $2/$12 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-09-11" },
|
|
36
38
|
"openai/gpt-5.6-sol": { "parse": 0.02, "ocr": 0.02, "extract": 0.02, "source": "https://developers.openai.com/api/docs/pricing (ESTIMATE from $4/$20 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-09-11" },
|
|
37
39
|
"openai/gpt-6-astra": { "parse": 0.05, "ocr": 0.05, "extract": 0.05, "source": "https://developers.openai.com/api/docs/pricing (ESTIMATE from $10/$50 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-09-11" },
|
|
40
|
+
"openai/gpt-6-luna": { "parse": 0.0005, "ocr": 0.0005, "extract": 0.0005, "source": "https://developers.openai.com/api/docs/pricing (ESTIMATE from $0.10/$0.50 per 1M tokens short context x ~1500 in + ~700 out per page)", "updated": "2026-10-08" },
|
|
38
41
|
"anthropic/claude-haiku-4-5": { "parse": 0.005, "ocr": 0.005, "extract": 0.005, "source": "https://platform.claude.com/docs/en/about-claude/pricing (ESTIMATE from $1/$5 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-09-11" },
|
|
39
42
|
"anthropic/claude-sonnet-5": { "parse": 0.01, "ocr": 0.01, "extract": 0.01, "source": "https://platform.claude.com/docs/en/about-claude/pricing (ESTIMATE from $2/$10 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-09-11" },
|
|
40
43
|
"anthropic/claude-opus-5": { "parse": 0.025, "ocr": 0.025, "extract": 0.025, "source": "https://platform.claude.com/docs/en/about-claude/pricing (ESTIMATE from $5/$25 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-09-11" },
|
|
44
|
+
"anthropic/claude-opus-5-5": { "parse": 0.02, "ocr": 0.02, "extract": 0.02, "source": "https://platform.claude.com/docs/en/models/opus-5-5/overview (ESTIMATE from $4/$20 per 1M tokens x ~1500 in + ~700 out per page)", "updated": "2026-10-08" },
|
|
45
|
+
"anthropic/claude-haiku-5-5": { "parse": 0.0005, "ocr": 0.0005, "extract": 0.0005, "source": "https://platform.claude.com/docs/en/models/haiku-5-5/overview (ESTIMATE from $0.10/$0.50 per 1M tokens for prompts up to 100k tokens x ~1500 in + ~700 out per page; $0.50/$2.50 above 100k)", "updated": "2026-10-08" },
|
|
41
46
|
"mathpix/pdf": { "parse": 0.005, "ocr": 0.005, "source": "https://mathpix.com/pricing/api (v3/pdf documents: $5/1k pages)", "updated": "2026-09-11" },
|
|
42
47
|
"mathpix/text": { "parse": 0.002, "ocr": 0.002, "source": "https://mathpix.com/pricing/api (v3/text image OCR: $0.002/image)", "updated": "2026-09-11" },
|
|
43
48
|
"datalab/fast": { "parse": 0.004, "ocr": 0.004, "source": "https://www.datalab.to/pricing (Convert fast/balanced: $4/1k pages)", "updated": "2026-09-11" },
|
|
@@ -57,7 +62,21 @@
|
|
|
57
62
|
"reducto/deep_extract": { "extract": 0.055, "source": "https://docs.reducto.ai/reference/credit-usage (Deep Extract $40/1k pages plus parse $15/1k)", "updated": "2026-09-11" },
|
|
58
63
|
"extend/extraction_performance": { "extract": 0.0625, "source": "https://docs.extend.ai/credits (extract 3 credits + parse_performance 2 credits per page @ $0.0125)", "updated": "2026-09-11" },
|
|
59
64
|
"extend/extraction_light": { "extract": 0.015, "source": "https://docs.extend.ai/credits (extract 0.7 credits + parse_light 0.5 credits per page @ $0.0125)", "updated": "2026-09-11" },
|
|
65
|
+
"opendocrouter/google/gemini-3.8-flash-low": { "parse": 0.005908, "ocr": 0.005908, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.75/0.08/3.75 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $5.91/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
66
|
+
"opendocrouter/google/gemini-3-flash": { "parse": 0.019667, "ocr": 0.019667, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.50/0.05/3.00 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $19.67/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
67
|
+
"opendocrouter/anthropic/claude-opus-5-5": { "parse": 0.04882, "ocr": 0.04882, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $4.00/0.20/20.00 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $48.82/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
68
|
+
"opendocrouter/anthropic/claude-haiku-5-5": { "parse": 0.001225, "ocr": 0.001225, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.10/0.01/0.50 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $1.22/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
69
|
+
"opendocrouter/openai/gpt-5.6-terra": { "parse": 0.019886, "ocr": 0.019886, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $2.00/0.20/12.00 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $19.89/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
70
|
+
"opendocrouter/openai/gpt-6-luna": { "parse": 0.000798, "ocr": 0.000798, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.10/0.01/0.50 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $0.80/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
71
|
+
"opendocrouter/infly/infinity-parser2-flash": { "parse": 0.004344, "ocr": 0.004344, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.24/0.24/1.16 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $4.34/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
72
|
+
"opendocrouter/opendatalab/mineru2.5-pro": { "parse": 0.000861, "ocr": 0.000861, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.08/0.08/0.39 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $0.86/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
73
|
+
"opendocrouter/xingchen-agi/teleocr": { "parse": 0.002702, "ocr": 0.002702, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.25/0.25/1.22 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $2.70/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
74
|
+
"opendocrouter/rednote-hilab/dots.mocr": { "parse": 0.00397, "ocr": 0.00397, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.31/0.31/1.53 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $3.97/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
75
|
+
"opendocrouter/paddlepaddle/paddleocr-vl-1.6": { "parse": 0.002111, "ocr": 0.002111, "source": "https://www.opendocrouter.ai/models (price version 2026-10-06: $0.24/0.24/1.20 per 1M input/cached/output tokens; per-page ESTIMATE = the site's average charge per page, $2.11/1k pages, without the $0.20/1M-token layout surcharge; real cost comes from charge_usd)", "updated": "2026-10-08" },
|
|
60
76
|
"tesseract/default": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (local tesseract binary; your own compute)", "updated": "2026-09-24" },
|
|
61
77
|
"docling/default": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (your docling-serve; your own compute)", "updated": "2026-09-24" },
|
|
62
|
-
"paddleocr/default": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (your PaddleOCR/PaddleX serving; your own compute)", "updated": "2026-09-24" }
|
|
78
|
+
"paddleocr/default": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (your PaddleOCR/PaddleX serving; your own compute)", "updated": "2026-09-24" },
|
|
79
|
+
"paddleocr/vl": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (your PaddleOCR-VL pipeline serving; your own compute)", "updated": "2026-10-08" },
|
|
80
|
+
"vllm/infinity-parser2-flash": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (infly/Infinity-Parser2-Flash on your vLLM server; your own compute)", "updated": "2026-10-08" },
|
|
81
|
+
"vllm/dots.mocr": { "parse": 0.0, "ocr": 0.0, "source": "self-hosted (rednote-hilab/dots.mocr on your vLLM server; your own compute)", "updated": "2026-10-08" }
|
|
63
82
|
}
|
|
@@ -54,7 +54,7 @@ pub trait Provider: Send + Sync {
|
|
|
54
54
|
fn no_jobs(provider: &str, model: &str) -> Error {
|
|
55
55
|
Error::unsupported_model(format!(
|
|
56
56
|
"{provider}/{model} has no asynchronous job API in PuffinParse; use parse() \
|
|
57
|
-
(providers with jobs: reducto, extend, llamaparse)"
|
|
57
|
+
(providers with jobs: reducto, extend, llamaparse, opendocrouter)"
|
|
58
58
|
))
|
|
59
59
|
.with_provider(provider)
|
|
60
60
|
}
|
|
@@ -86,6 +86,25 @@ pub fn resolve_api_key(request: &DocumentRequest, env_var: &str, provider: &str)
|
|
|
86
86
|
})
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/// Check that a value spliced into a provider hostname (an AWS region, a Google location) is a
|
|
90
|
+
/// single DNS label. Without this, `provider_options.region = "evil.example/"` would turn
|
|
91
|
+
/// `https://textract.{region}.amazonaws.com` into a request — credentials attached — to another host.
|
|
92
|
+
pub(crate) fn host_label(provider: &str, what: &str, value: &str) -> crate::error::Result<()> {
|
|
93
|
+
let ok = !value.is_empty()
|
|
94
|
+
&& value.len() <= 63
|
|
95
|
+
&& value.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-')
|
|
96
|
+
&& !value.starts_with('-')
|
|
97
|
+
&& !value.ends_with('-');
|
|
98
|
+
if ok {
|
|
99
|
+
Ok(())
|
|
100
|
+
} else {
|
|
101
|
+
Err(crate::error::Error::input(format!(
|
|
102
|
+
"{provider}: invalid {what} '{value}' (expected lowercase letters, digits and '-', e.g. us-east-1)"
|
|
103
|
+
))
|
|
104
|
+
.with_provider(provider))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
89
108
|
/// Resolve base URL: request override, then `<PREFIX>_BASE_URL` env, then default.
|
|
90
109
|
pub fn resolve_base_url(request: &DocumentRequest, env_var: &str, default: &str) -> String {
|
|
91
110
|
request
|
|
@@ -139,3 +158,20 @@ pub fn file_part(data: bytes::Bytes, input: &crate::types::DocumentInput) -> req
|
|
|
139
158
|
.expect("static mime is valid"),
|
|
140
159
|
}
|
|
141
160
|
}
|
|
161
|
+
|
|
162
|
+
#[cfg(test)]
|
|
163
|
+
mod tests {
|
|
164
|
+
use super::host_label;
|
|
165
|
+
|
|
166
|
+
#[test]
|
|
167
|
+
fn host_label_accepts_regions_and_rejects_host_injection() {
|
|
168
|
+
for ok in ["us-east-1", "eu", "us-gov-west-1", "ap-southeast-2"] {
|
|
169
|
+
assert!(host_label("p", "region", ok).is_ok(), "{ok}");
|
|
170
|
+
}
|
|
171
|
+
for bad in ["", "evil.example/", "evil.example#", "a.b", "x:443", "us@evil", "-us", "us-", "US-EAST-1", "eu/x"]
|
|
172
|
+
{
|
|
173
|
+
let e = host_label("p", "region", bad).unwrap_err();
|
|
174
|
+
assert_eq!(e.kind, crate::error::ErrorKind::Input, "{bad}");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|