Loading...
Loading...
Two primitives of the Nutrient Data Extraction API. `parse` (`/extraction/parse`) returns the whole-document model — a structural JSON of typed elements with bounding boxes, or whole-document Markdown — for RAG ingestion, search indexing, content migration, or layout-aware understanding. `extract` (`/extraction/extract`) returns just the fields you define in a JSON Schema, each with a per-field citation grounding it to a page region. Route to `extract` for "pull the invoice number and total", "extract these fields", "map to my schema", or "with citations"; route to `parse` for "parse this document", "whole-document Markdown", "chunk for embeddings", or "extract every table/element" (no target schema). Triggers include parse this document, extract layout, RAG pipeline, schema extraction, field extraction, cited fields, invoice/form field extraction, document understanding.
npx skill4agent add pspdfkit-labs/nutrient-skills document-extraction-apiparsescripts/parse.pyextractscripts/extract.py| The request is about… | Use | Why |
|---|---|---|
| Named target fields — "the invoice number and total", "these fields", "map to my schema", "with citations" | | One call returns your fields, cited — no need to walk every element |
| The whole document — "parse this", "whole-document Markdown", "chunk for embeddings", RAG, search indexing, migration | | Whole-document model / Markdown for open-ended retrieval |
| Every table / all key-value regions (no target schema) | | Enumerate all elements; |
grounded-rag-ingestion/builddocument-processor-apiextractparseparseparse/extraction/extracttype: objectextractoutput.dataoutput.metadataoptions.includeCitations# Pull schema-defined fields from a local invoice, with citations (default)
uv run scripts/extract.py --input invoice.pdf --schema fields.json --out result.json
# From a URL, higher-accuracy mode, persist the run
uv run scripts/extract.py --url https://example.com/form.pdf --schema fields.json \
--out result.json --mode understand --store-runextracttextstructure--yesreferences/extract-output-and-citations.md/builddocument-processor-apiNUTRIENT_EXTRACT_API_KEYexport NUTRIENT_EXTRACT_API_KEY="pdf_live_..."scripts/cd <directory containing this SKILL.md> && uv run scripts/<script>.py --help/extraction/parse403NUTRIENT_EXTRACT_API_KEYNUTRIENT_API_KEY/extraction/parse/build/signunderstandagenticforminvoicereceiptapplicationclaimunderstandchartinfographicagenticscannedimage-basedphotographedhandwrittenscreenshotstructuretextmarkdownspatialstructurespatial| User intent | Mode | Output format | Cost | Notes |
|---|---|---|---|---|
| RAG / search indexing / content migration — born-digital PDF | | | 1 cr/pg | Cheapest path; no OCR or AI needed |
| RAG / search indexing — scanned or image-based PDF | | | 1.5 cr/pg | OCR required before Markdown assembly |
| Form / invoice — enumerate all key-value regions (no target schema) | | | 9 cr/pg | AI key-value + table detection. For named fields ("the invoice number and total"), use |
| Layout-aware document understanding | | | 9 cr/pg | Semantic paragraph roles (Title, SectionHeader, etc.) |
| Deep visual understanding (charts, diagrams, alt text) | | | 18 cr/pg | VLM adds alt descriptions on every picture element |
| Default / ambiguous intent | | | 1.5 cr/pg | Good balance: OCR + spatial elements, low cost |
agenticunderstandstructuretextpages × cost_per_pagemode='text'output_format='spatial'# Default: structure mode, spatial output
uv run scripts/parse.py --input doc.pdf --out out.json
# Markdown for RAG (text mode — cheapest)
uv run scripts/parse.py --input doc.pdf --out out.md --output-format markdown --mode text
# Enumerate all key-value regions of a form (understand mode) — for NAMED fields use extract
uv run scripts/parse.py --input doc.pdf --out out.json --mode understand
# Agentic (VLM alt text on pictures)
uv run scripts/parse.py --input doc.pdf --out out.json --mode agentic/parseoutput.elements(page.pageIndex, readingOrder)paragraphhandwritingtextcells[]tablecell.rowcell.columnpairs[]keyValueRegion.key.value.value.valuelatexformulaclassificationaltDescriptionagenticpicture--output-format markdownreferences/parse-output-filtering.mdparse.py