Free, verified field extraction from document images (invoices, bank checks, flyers, receipts, forms): two independent vision-model reads must agree before any field is sealed; everything else is a reason-coded refusal. Bring your own provider keys.
Verified field extraction from document images — free, with your own model keys.
Send pairseal a photo or scan of an invoice, a bank check, a receipt, a retail flyer, a shelf label, or a form, and it returns the fields and line items that two independent vision-model reads agree on — sealed, with the model pair recorded. Everything the two reads cannot agree on comes back as a reason-coded refusal, never as a guess.
Commercial document-extraction APIs charge roughly $0.08–0.30 per document for receipts and invoices, and their catalogues stop there: no flyer product, no agreement gate, no refusal semantics, no validity windows. pairseal is the free, multipurpose alternative: it runs entirely with your own provider keys (free tiers work), and images go only to the providers you configure.
git clone https://github.com/ranadhir19/pairseal.git cd pairseal pip install . # core: Python >= 3.10, standard library only Why a gate, not just an extractor Vision models read images well. What they do not do is tell you when they have misread one — and in a price or amount field, a misread is not a typo, it is a wrong number served as fact. pairseal's answer is structural:
A refusal is a success state of this tool, not an error. The gate may refuse a truth; it never invents one.
Document type is user-specified (--doc-type) or auto-detected from the reads. Field kinds are compared by kind: money in integer cents, dates as calendar dates, text on a normalised token key.
Money formats are resolved from the text as printed, because that is where ambiguity lives: 5.99, $5 99, and 5/99 resolve; a bare 599 does not ($599, $5.99, and 599 cents are all live readings) and is refused as ambiguous_price_format.
pairseal runs with your keys; images go only to the providers you configure. Nothing is sent anywhere else, and there is no pairseal server.
Corpus logs follow a strict rule for sensitive fields — bank-check amounts and account/routing numbers, and any field whose name mentions account, routing, ssn, or card: the log stores the field name, the agreement outcome, and the image hash only. Never the extracted value, and never raw read text that contains it. Check records are value-free by construction; the self-test verifies this on every run.
Readers are pluggable. A run names its pair explicitly, and every output record carries the pair's identity — provider, family, and the exact requested and API-reported model ids for both readers — plus a distance class: cross_provider, same_provider_cross_family, same_family, or single_reader.
Credentials are never read from files or arguments and never printed: inside Muse they come from the connector credential store; standalone, from the standard environment variables (GEMINI_API_KEY / GOOGLE_AI_STUDIO_API_KEY / GROQ_API_KEY).
Honest limit — agreement is not independence. Two models can be wrong together: published measurement (Kim et al., Correlated Errors in Large Language Models, ICML 2025) found that when two LLMs are both wrong they agree on the same wrong answer far above chance, and that same-developer pairs correlate the most. A same_provider_cross_family pair — two model families behind one provider's API — is a weaker gate than a cross-provider pair, and the record says which one you ran. Treat sealed output as verified by agreement, with the strength the pair metadata states — not as ground truth.
pip install . # core: Python >= 3.10, standard library only pip install .[selftest] # + Pillow, for the synthetic-fixture self-test Use # auto-detect the document type, default pair, append to a corpus log pairseal extract invoice.png --corpus corpus.jsonl # name the type and the pair explicitly pairseal extract check.jpg --doc-type check \ --reader gemini:gemini-3.5-flash --reader gemini:gemma-4-31b-it # generic form with your own fields pairseal extract form.png --doc-type generic --fields member_id,visit_date # inspect a corpus log pairseal verify-corpus corpus.jsonl Exit codes: 0 — at least one field or item sealed; 3 — the gate refused everything (a success state of the gate, distinct from failure); 2 — usage/config error.
from pairseal import extract, make_reader record = extract( open("flyer.jpg", "rb").read(), readers=[make_reader("gemini:gemini-3.5-flash"), make_reader("gemini:gemma-4-31b-it")], doc_type="flyer", source={"url": "https://example.com/flyer", "retailer": "Example Mart", "posted_at": None, "note": None}, ) print(record["tuples"]) # sealed items only print(record["refusals"]) # everything else, reason-coded Corpus log Every run produces one JSON record (schema 1.1, documented in docs/corpus-schema.md): image hash (never the image), source provenance, the model pair and its distance, both reads raw and parsed (redacted for sensitive types), the validity window where one applies, sealed fields and items, and every refusal with its reason. The log is the audit trail of a deployment — what was sealed, what was refused, by which pair, on which image — and verify-corpus validates and summarises it.
The fault-injection self-test renders synthetic documents with known ground truth — a clean invoice, a check whose written amount contradicts its numeric amount (planted; the gate must catch it even though the scripted reads agree), flyer traps (a bare 599, a price conflict, a single-read product, an expired window, an unreadable render), a receipt, a generic form — and judges the gate against them with scripted readers. It measures the gate deterministically and offline; live model accuracy is a property of the models, measured by real corpus runs, not here.
Latest: 10/10 fixtures, 2/2 controls passed — see SELFTEST_RESULTS.md. Global invariant: no sealed field or item ever carries a value that differs from the ground truth rendered in its image.
MIT — see LICENSE. Compliance record: COMPLIANCE.md.
document-extraction invoice receipt flyer vision-llm document-understanding information-extraction verification agreement-gate
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




