The most expensive part of asking an LLM about a PDF is usually the PDF. Ask 20 questions about a 100-page PDF in 20 separate API calls, and you've sent 2,000 pages of input. At Anthropic's estimate of 1,500 to 3,000 text tokens per page, that's 3 to 6 million input tokens before you even count a single page image. While prompt caching can help reduce the bill, you're still sending the whole file every time. That means each new question still has the model working out table structure from a text layer that doesn't even know what a table is.


The better pattern is to separate ingestion from answering questions. Parse the document once, store the result, and send the model the sections or fields it needs, with page references so every answer can be checked. 


That's the job the Nutrient Data Extraction API is built for: it turns PDFs, scans, images and Office files into Markdown or structured JSON, and it can tie each extracted value back to the page and position it came from.


To see why this matters, start with what an LLM API actually receives when you send it a PDF.

Five ways raw PDFs break in LLM pipelines

Anthropic's and OpenAI's APIs handle PDFs in a similar way.


Anthropic's docs say Claude converts each page into an image, and the text from each page is extracted and provided alongside it. OpenAI's docs describe the same approach for vision-capable models: both the extracted text and page images go into the model's context.


So a "raw PDF" is really two things:


  1. The PDF's text layer. This is whatever text is stored in the file, in whatever order the software that made it decided to store it. That's often not the order a person actually reads the document in.
  2. A picture of every page. The model can look at it, but it has to work out the layout from pixels on every call.


That's surprisingly good for a quick question about a short document. It starts to fall apart when you need exact numbers, from long documents, or the same document queried again and again. 

What does an LLM see when you send it a PDF

1. Tables turn into word soup

A PDF doesn't store tables. It stores bits of text at coordinates. In the text layer, a row like "Q3 revenue | 4.2M | 3.9M" can come out as a column of numbers with the labels three lines later. The page image helps, but the model has to rebuild the grid from pixels every time. That's where line items drift, merged cells collapse and a number lands in the wrong column. It gets worse when a table crosses a page break and comes back as several unrelated fragments.

2. Reading order is a guess

Two-column papers, sidebars, footnotes and headers that repeat on every page all get stored in whatever order the PDF writer chose. A model reading the text layer can stitch the end of column one onto a footnote, then carry on into column two. Nothing in the output tells you it happened.

3. Scans have no text at all

A scanned contract or a phone photo of a receipt usually has no text layer unless someone ran OCR on it first. The model gets only the image and does its own reading. When it misreads a digit, there's no text layer to compare against, so nothing flags the mistake.

4. Answers are hard to check at field level

Ask a model what the termination clause says and you'll get a fluent paragraph. Some APIs, including Claude's citations feature, can point to the passage an answer came from. That helps, but you're still trusting the model's reading of the page, and you don't get a typed value you can validate against a schema. For anything that gets audited, like finance, insurance, legal or healthcare, an answer you can't trace to a specific value and location is still a draft.

5. You pay for every page, every time

Anthropic estimates 1,500 to 3,000 text tokens per page, plus image tokens for each page image. OpenAI's docs also note that sending both text and page images can increase token usage. Prompt caching can cut the cost of repeat reads, but it doesn't fix the tables, the reading order or the scans. Anthropic's docs also warn that dense PDFs can fill the context window before you hit the page limit.

How Nutrient Data Extraction fixes each one

Data Extraction splits the job in two. It reads the document once and turns it into structure. Your LLM reasons over that structure as many times as you like. You keep whichever model you already use. It just stops doing the parser's job.


Problem with raw PDFs

What the Nutrient Data Extraction API does

Tables turn into word soup

Detects tables and returns them as real tables in Markdown or JSON

Reading order is a guess

Returns headings and text in reading order

Scans have no text

Runs OCR on scans and images, so a scanned contract parses like a digital one

Answers are hard to check

Returns a citation for each extracted field, with the page number, a bounding box and a confidence score

You pay for every page, every time

Parses each page once; you store the result and send the model only what it needs


It covers the whole document pipeline with four endpoints:


Endpoint

What it does

Use it when

Parse (POST /extraction/parse)

Returns the whole document as Markdown, as typed spatial elements (paragraphs, tables, key-value pairs) with bounding boxes, or both

You want to ask open questions over a document, or feed a RAG index

Extract (POST /extraction/extract)

Returns only the fields you ask for, shaped to your own JSON Schema, with optional citations for each value

You already know the fields you need, such as party names, invoice totals or policy numbers

Classify (POST /extraction/classify)

Scores a document against labels you define and returns ranked predictions

You need to route documents (contract, invoice, claim form) before extraction

Split (POST /extraction/split)

Finds document boundaries in a merged file and returns each document's page range with a confidence score

One scanned PDF contains several documents


Every endpoint also has an async version (/extraction/{parse,extract,classify,split}/async) that returns a queued run you can poll, and GET /extraction/runs/{runId} returns a stored run's status, cost and result files. Together they cover a full intake flow: split a scanned batch into documents, classify each one, then extract the fields that document type needs.

Pick a processing mode per document

You choose how much work the API does per page, so you pay for depth only where a document needs it:


Mode

What it does

Parse price per 1,000 pages

text

Fast Markdown extraction, no OCR or AI

$1

structure

OCR with typed elements and bounding boxes

$1.50

understand

Layout analysis, table detection and text recognition, without a vision-language model (the default)

$9

agentic

Builds on understand with a vision-language model, for the hardest documents

$18

auto

Picks structure, understand or agentic for each page and bills that page's rate

$1.50 to $18


Extract runs a parse stage first, so it's billed at the parse mode's rate plus an extraction charge.


See Data Extraction pricing for current rates. The free plan includes $5 of usage every month, with no credit card needed.

How well it handles whole documents

Most parser benchmarks score one page at a time, so they never see the errors that happen at page breaks. Nutrient built WholeDoc Bench to score documents from the first page to the last. Season 1 runs 13 parsers 19 ways on 480 documents, built around what breaks parsers in real work: tables that run across pages, scans, charts and barcodes.


The Data Extraction API's agentic mode scored highest overall, 86.2 at 1.8¢ per page. Understand mode scored 80.8 at 0.9¢ per page. The best frontier LLM tested scored 67.1 at about 18¢ per page, roughly 10 times the price of agentic mode. It's Nutrient's own benchmark, so the code and a 10-document sample are public, and you can run it on your own documents.

What it looks like in code

The examples below use Python. Set ANTHROPIC_API_KEY and NUTRIENT_API_KEY as environment variables first. 

Step 1: Measure what raw PDFs cost you

Anthropic's token counting endpoint is free and runs no generation, so you can compare the raw PDF against the Markdown the Data Extraction API returns before you change anything in your pipeline.


import base64 import os import anthropic import requests client = anthropic.Anthropic() MODEL = "claude-sonnet-5-5" PDF_PATH = "contract.pdf" QUESTION = "What is the termination notice period?" # Raw PDF: text layer + page images with open(PDF_PATH, "rb") as f:     pdf_b64 = base64.standard_b64encode(f.read()).decode() raw = client.messages.count_tokens(     model=MODEL,     messages=[{         "role": "user",         "content": [             {"type": "document",              "source": {"type": "base64", "media_type": "application/pdf", "data": pdf_b64}},             {"type": "text", "text": QUESTION},         ],     }], ) # Parse once with the Nutrient Data Extraction API and store the Markdown with open(PDF_PATH, "rb") as f:     resp = requests.post(         "https://api.nutrient.io/extraction/parse",         headers={"Authorization": f"Bearer {os.environ['NUTRIENT_API_KEY']}"},         files={"file": f},         data={"instructions": '{"mode":"understand","output":{"format":"markdown"}}'},         timeout=300,     ) resp.raise_for_status() markdown = resp.json()["output"]["markdown"] # In a real pipeline you'd retrieve only the relevant chunks; here we send it all parsed = client.messages.count_tokens(     model=MODEL,     messages=[{"role": "user", "content": f"{markdown}\n\n{QUESTION}"}], ) print(f"raw PDF: {raw.input_tokens:,} tokens") print(f"parsed:  {parsed.input_tokens:,} tokens") 


Tables come back as HTML inside the Markdown by default, which keeps merged cells intact. On a 3-page sample contract, the raw PDF came to 6,998 input tokens and the parsed Markdown to 3,378, about half, and that's with the whole parsed document sent. Once you retrieve only the two or three relevant chunks, the difference is much larger.


And you parse once: a 100-page document in understand mode costs $0.90 to parse, and every later question reuses the stored Markdown with no extra parsing cost.

Step 2: Extract fields with citations instead of asking for a summary

When you know what you need, skip the summary and ask the Extract endpoint for specific fields against a schema. Turn on strict so the output conforms to your schema, and includeCitations so each value comes back with its source.


import os import requests resp = requests.post(     "https://api.nutrient.io/extraction/extract",     headers={"Authorization": f"Bearer {os.environ['NUTRIENT_API_KEY']}"},     json={         "url": "https://example.com/contract.pdf",         "schema": {             "type": "object",             "properties": {                 "party_names": {"type": "array", "items": {"type": "string"}},                 "effective_date": {"type": "string", "description": "ISO 8601 date"},                 "termination_notice_days": {"type": "number"},             },             "required": ["party_names", "effective_date"],         },         "instructions": "Extract values exactly as shown. Do not infer missing values.",         "parseConfig": {"mode": "agentic"},         "options": {"strict": True, "includeCitations": True},     },     timeout=120, ) resp.raise_for_status() output = resp.json()["output"] fields = output["data"]         # values shaped to your schema citations = output["metadata"]  # same shape as fields: page, bbox, match, confidence 

Step 3: Send only uncertain values to a person

The citation metadata mirrors your data field for field. Each value carries a match label that says how well it was grounded in the document, plus pageNumber, bbox and a confidence score when one is available. Nutrient's docs recommend routing fuzzy_match and not_found values to review, so a few lines of code give you a review queue that points straight at the right page:


def review_queue(data, meta, path=""):     """Yield (field, value, page) for every value the API couldn't ground exactly."""     meta = meta or {}     if isinstance(data, dict):         for key, value in data.items():             yield from review_queue(value, meta.get(key), f"{path}.{key}" if path else key)     elif isinstance(data, list):         for i, item in enumerate(data):             yield from review_queue(item, meta[i] if i < len(meta) else None, f"{path}[{i}]")     elif meta.get("match") in {"fuzzy_match", "not_found"}:         yield path, data, meta.get("pageNumber") for field, value, page in review_queue(fields, citations):     print(f"Review {field} = {value!r} (page {page})") 


Everything else goes straight through to your LLM or your system of record. You get the same JSON shape for every contract, whether it arrived as a clean digital PDF or a phone scan, and every value can be traced back to the page it came from.


You pay to process each contract once. Your LLM then works with three clean fields instead of every page's text and images on every question.

When is sending a raw PDF fine?

Sending the PDF straight to the model is perfectly reasonable when:


  • It's a one-off question about a short, clean, digital document.
  • You're prototyping and want to know if the idea works at all.
  • The answer is a summary or an opinion, not a number someone will act on.
  • A person reads the answer next to the document anyway.


Parsing pays off when the same documents get queried more than once, when the numbers have to be right, or when someone has to prove where a value came from. The trouble starts when the raw-PDF pattern quietly becomes production: thousands of documents, exact figures, scans, and nobody checking. That's the moment to add Data Extraction to your pipeline.

Parse once, ask many times

LLMs are good at reasoning and not very good at being a PDF parser. Parse each document once with Data Extraction, keep the citations, and send the model tables and fields that are already in the right order. You stop paying to resend the whole file with every question, the answers are easier to check, and every value can be traced back to its source.


Pick the worst PDF in your pipeline this week, run the token count above, and compare what the model sees raw against what it sees after parsing. To run it on your own documents, get a free Nutrient Data Extraction API key. The free plan includes $5 of usage every month.