Model API
Document extraction with local parsing and a model API
Docling parses each document to markdown locally, a closed model API (GPT-5, Claude or Gemini) fills a JSON schema under structured outputs, code validates the result, and rows that fail go to a person. The pipeline and the parsing are yours; only the model is rented.
- Source
- Editorial recipe — no step evidence has been fetched yet
- Verified
- Evidence not verified
- Confidence
- Low
01Objective
Extract structured records from varied documents by parsing them on your own machines and sending only the parsed text to a closed model constrained to a JSON schema, with validation and a human-review path in code you own.
- use caseData extractionPulling defined fields out of unstructured text into a schema — from forms, reports, emails, filings or web pages. The general case of invoice extraction, and the step that turns documents into something a database can hold.
- use caseDocument classificationSorting incoming documents into types and routing them — which team, which folder, which workflow, which retention rule. Usually the first step of a larger pipeline and the cheapest place to remove manual handling.
- use caseInvoice extractionReading supplier invoices — header fields, line items, tax, totals — into structured records. The extraction step only. What happens to the record afterwards is invoice processing automation.
- use caseOCRTurning images of text — scans, photographs, faxes, historic files — into machine-readable text with layout. The step everything else depends on: no extraction, search or classification pipeline is better than the text layer underneath it.
- use caseReport generationProducing a recurring document — a management pack, client update, board summary, compliance return — from data and prior text. The template and the data are fixed; the narrative around them is what takes the time.
02Recommended stack
| Role | Component |
|---|---|
| Inference | Closed model API (OpenAI, Anthropic or Google Gemini) |
| Ingestion | Docling |
| Observability | Human review queue |
| Orchestration | Extraction pipeline (your own) |
| Storage | Object storage (per-stage landing zone) |
Architecture and data flow
Components
- Operations team (exception queue) — people
- Docling (local OCR / parse) — storage
- Extraction pipeline + review screen — application
- Normalisation + validation service — retrieval
- Extracted records + exception queue — database
- Object storage (landing zone) — storage
- Vendor model API — inference server
- Closed model under structured outputs — model
Connections
- Operations team (exception queue) to Extraction pipeline + review screen — HTTPS (confidential data)
- Docling (local OCR / parse) to Normalisation + validation service — documents to index (confidential data)
- Extraction pipeline + review screen to Normalisation + validation service — question + user groups (confidential data)
- Normalisation + validation service to Extracted records + exception queue — documents + permissions (confidential data)
- Extraction pipeline + review screen to Extracted records + exception queue — chats, users, settings (personal data)
- Normalisation + validation service to Object storage (landing zone) — original files (confidential data)
- Normalisation + validation service to Vendor model API — prompt + retrieved passages (confidential data)
- Vendor model API to Closed model under structured outputs — loaded weights
External data transfer · YES
- confidential content leaves your control on the Normalisation + validation service → Vendor model API link.
- Parsing runs on your own machines; the model call sends the parsed text to the vendor, and that text is the content — the transfer to govern by contract.
- The originals never leave the landing zone; only the extracted text is sent, and only to fill the schema.
03Suitable for
- Organisation size
- 10–5000 employees
- Data classes
- confidential, personal
- Constraints
- a team that can build and run a small pipeline, or an implementation partner who will; a paid business account with the model vendor; agreement that the parsed document text may leave the network under contract
- Industries
- Professional services, Accounting, Logistics, Financial services, Technology
- Jurisdictions
- any
04Hardware
No hardware profile was sized for this answer.
Indicative costUSD · one-off plus monthly
- Software
- Docling is MIT-licensed and the pipeline is yours. What you pay the model vendor is metered and sits on the model line.
- US$0
- Model usage
- Not estimated here: priced per token — see the cost section, which multiplies a fetched price by the usage band read from your brief. Nothing in this seed asserts a price.
- Not estimated
- Parsing compute and storage
- Not estimated: Docling runs on CPU for most formats (a GPU speeds up VLM parsing of scanned documents), plus object storage per gigabyte. Priced per your own infrastructure — it scales with document volume, not user count.
- Not estimated
- Implementation (6–16 FDE-days)
- 6–16 FDE-days at US$760–1940 per day, converted from the HK$6,000–15,000 band at the HKMA Linked Exchange Rate band of HK$7.75–7.85 to one US dollar. One-off; excludes internal staff time.
- US$4,560 – US$31,040
- The model line is the metered one and scales with document volume; the cost section computes it from a fetched price and the usage band.
- Implementation covers the parsing stage, the schema and extraction, validation, the review queue and an accuracy measurement; it excludes the metered model bill.
- Assumes a system to write the validated records into already exists.
05Difficulty
3 / 5
A project week with Linux, Docker and GPU experience
06Skills
- API integrationapi-integration
- development
- Data engineeringdata-engineering
- data
- OCR and document parsingocr
- ml
- Prompt engineeringprompt-engineering
- ml
- Pythonpython
- development
- Security hardeningsecurity-hardening
- security
07Deployment steps
Commands are copied from each project’s own documentation, and the page they came from is linked under the step. 0 of 7 steps currently open an evidence record. The rest are linked to their source; §10 says which of those documents were fetched and which were fetched without their anchor being found — two different states, named differently there.
- 01
Parse each document to markdown with Docling, locallyversion-sensitive
AssessmentRun Docling on your own machines so the reading happens before anything leaves the network. It offers "extensive OCR support for scanned PDFs and images" and "local execution capabilities for sensitive data and air-gapped environments"; the CLI over a file "generates a .md file in the current directory containing structured document content". Parse once and keep the markdown.
pip install doclingdocling ./inbox/invoice-0001.pdfwrites structured markdown next to the input
- 02
Keep a replayable landing zone
AssessmentOne bucket per stage — arrived, parsed, extracted, failed — with versioning and a lifecycle rule. Because Docling’s parse runs locally and is deterministic, keeping the originals and the markdown means a schema change or a model swap is a re-run over what you already have, not a fresh request to the business.
- 03
Have the model fill a JSON schema, not write proseversion-sensitive
AssessmentSend the parsed markdown, not the raw image, and constrain the output to a schema. OpenAI describes structured outputs as "a feature that ensures the model will always generate responses that adhere to your supplied" JSON schema; the other vendors have the same capability. Feeding text rather than an image keeps the reading and the normalising separately debuggable.
- 04
Check in code what the schema cannot guarantee
AssessmentA schema-conformant answer is not a correct one: structured outputs guarantee the shape, not the truth. Totals that add up, dates that parse, a supplier that exists in your master data, a currency the contract allows — all of that is arithmetic and lookups, and belongs in code after the model. Record every failed check against the document.
- 05
Route validation failures to a person
AssessmentRows that fail a check go to a review queue rather than through. Sort the queue by the reason it failed, not by arrival time, and keep the reviewer’s correction — it is the ground truth you measure against and the training data for the next prompt iteration.
- 06
Verify the vendor’s data terms before real documents flowversion-sensitive
AssessmentOnly the parsed text reaches the model, but that text is the document. Before real content goes near the endpoint, confirm the commercial data terms: Anthropic states that "by default, we will not use your inputs or outputs from our commercial products" to train, and OpenAI’s enterprise page describes commitments giving you "ownership and control over your business data". Check whether a zero-data-retention mode exists on your account.
- 07
Measure field-level accuracy on a labelled sample
AssessmentReport accuracy per field, not per document: a pipeline that reads the invoice number right 99% of the time and line quantities right 80% has one number worth quoting and one worth fixing. Because Docling’s OCR is deterministic, hold back a labelled set the pipeline never tunes on and re-run it whenever the model version or the prompt changes.
08Compliance considerations
Structured issue-spotting to support your own review — not legal advice. Verify against the cited primary sources and your counsel.
Applies everywhere
Prompt leakage · Confidentialityhigh
Parsing locally does not keep the content in: the parsed text is sent to the model vendor, and it is the document. Decide what document types may go to the API, and keep anything under a duty of confidence out unless the contract and consent allow it.
Data processing agreement · Subprocessors · Model traininghigh
You need a DPA that covers the API, the subprocessor list, and the no-training default for the plan you buy. Anthropic states it does not use commercial inputs or outputs to train by default; confirm the equivalent for whichever vendor you call and whether a zero-data-retention mode is available.
Human oversight · Automated decision-makinghigh
A schema-conformant extraction can still be wrong. Where an extracted value drives a decision about a person, the code validation and the human-review queue are the oversight step — keep the record of who reviewed and corrected what.
Personal data · Retentionmedium
The landing zone holds the originals and the parsed text, both often personal data. Apply retention to every stage — arrived, parsed, extracted, failed — not only the final records, and minimise what the pipeline keeps.
09Alternatives
A managed extraction service in your own cloud
When you are already on a hyperscaler, its document service gives per-field confidence and prebuilt models for common types, inside your own account rather than at a separate vendor.
- — Per-field confidence and prebuilt models for invoices, receipts and IDs
- — Ties the pipeline to one cloud’s service instead of a portable local parser
azure-document-intelligenceamazon-textractgoogle-document-ai
Self-hosted, if the text may not leave the network
Keep Docling but serve the extraction model on your own GPU with vLLM, so nothing — not even the parsed text — reaches a vendor.
- — No vendor sees the parsed text
- — A weaker model and a GPU to size and operate
- Self-hostedInvoice capture and extractionInvoices arrive by email or watched folder, Docling converts them (OCR included), a local vision-capable model fills a JSON schema under constrained decoding, code checks the arithmetic and the supplier against your master data, and n8n posts the clean ones while routing the rest to a person.
- Private cloudDocument extraction pipeline in your cloud accountA landing zone in object storage, a managed document-understanding service (Azure AI Document Intelligence, Amazon Textract or Google Document AI), a managed model constrained to a JSON schema, validation in code, and a confidence-thresholded review queue — all in the region you pin, reached over private networking.
10Evidence
Not yet in the ledger
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
- OpenAI — Enterprise privacy
Vendor page
not yet fetched
11Community
Deployed this stack, or hit something this page does not cover? Corrections, sources and implementation reports are what keep a recipe worth reading.
Improve this page
Sign in to contribute
From the field
0 deployments · 0 questions
Nobody has reported deploying this here yet, and no question has been opened against this page. Both appear once a reviewer accepts them.
12Hire an FDE
If you would rather not build it, we can introduce a forward-deployed engineer who has deployed this stack before. The enquiry form starts from this recipe.