PDF VectorPDF Vector
Back to all articles

AI Invoice Data Extraction That Ops Can Trust

How AI invoice data extraction works on real invoices: fields to extract, multi-page line items, retries, review design, per-page costs and a rollout plan.

AI Invoice Data Extraction That Ops Can Trust

AI invoice data extraction reads an invoice the way a person does, by its content and layout rather than fixed coordinates, and returns the fields you ask for as structured data: vendor, invoice number, dates, totals, tax and every line item. For operations and finance teams the question is not whether it can read invoices, but whether its output can be trusted enough to post without re-keying. That depends on four things you control: the schema you ask for, the model tier, the validation you run on every result, and how exceptions reach a person. This guide covers each, with a realistic multi-page example, costs and a rollout plan.

What changes compared with template-based capture

Template capture tools record where each field sits on a given vendor's layout. They work well for a few stable vendors and break when a layout changes: a new logo, a moved column, a second page. Every new vendor means a new template, and someone has to maintain them.

AI extraction removes the per-vendor setup:

Template captureAI extraction
New vendorBuild and test a templateSame request as every other vendor
Layout changeTemplate breaks, often silentlyUsually no change needed
Multi-page line tablesNeeds special rules per layoutRead as one document
Scans and photosOCR plus template, fragileScanned PDFs are OCR'd on mini and above
Output shapeFixed by the toolDefined by your JSON Schema
ControlRules you wroteValidation you run on the output

The last row is the honest trade-off. A template either matches or fails loudly; an AI model usually returns plausible-looking values even when it misread the page. That is why validation (covered below) is part of the design, not an afterthought.

The fields to extract

Ask for what your downstream systems need and what lets the invoice prove itself:

  • Header: vendor name, vendor tax ID, invoice number, invoice date, due date, PO number, currency.
  • Totals: subtotal, discount, tax, total (as separate numbers, so you can check the arithmetic).
  • Line items: description, quantity, unit price, amount, and optionally SKU or tax rate per line.
  • Payment details: IBAN or account number, if your invoices carry them (useful for fraud checks).

Put these in a JSON Schema and send it with a short prompt that sets conventions: dates as YYYY-MM-DD, amounts as plain numbers, negative values on credit notes, 0 when there is no tax. The free JSON Schema Editor builds a schema visually; the invoice-to-JSON tutorial shows a complete schema and request.

A messy example: the four-page logistics invoice

Clean one-page invoices are not where extraction tools differ. Consider a freight vendor's invoice:

  • Page 1 has the header and the first 10 shipment lines.
  • Pages 2 to 4 hold 60 more lines, with the table header repeated on each page.
  • Lines are grouped by route, with a subtotal row after each group.
  • Some rows are descriptive only ("Fuel surcharge applied per contract §4") with no amount.
  • Tax and the grand total appear only on the last page.

Weak extraction fails here in predictable ways: it stops after page 1, counts the route subtotals as line items (so lines add up to double the subtotal), turns the descriptive rows into zero-amount lines, or takes the last route subtotal as the invoice total.

What helps:

  1. Send the whole file in one request. Send all pages in one request so lineItems can cover every page and the total from the last page is read with the header from the first, and use the line-sum check to confirm it did.
  2. Say what is not a line item. Add to the prompt: "Do not include repeated table headers, group subtotal rows or rows without an amount as line items."
  3. Check the line sum. If 70 lines add up to the subtotal, nothing was dropped or double counted. If they add up to roughly twice the subtotal, subtotal rows slipped in.
  4. Escalate the tier for hard layouts. If the check fails on auto or mini, retry on pro or max.

The same thinking applies to other finance documents with long tables: bank statements (different date formats, running balances, separate debit and credit columns) and payout or settlement reports. PDF Vector has dedicated bank statement endpoints for statements, and the generic Document Extract for reports.

Making the call

Invoice Extract takes the file (as a url, a multipart file upload or a base64 string), a prompt, a schema and a model. Here is the extraction plus a retry on a higher tier when the arithmetic does not hold, using the TypeScript SDK:

import { createClient } from "@pdfvector/client";

const client = createClient({ apiKey: process.env.PDFVECTOR_API_KEY });

const prompt =
  "Extract the vendor, vendor tax ID, invoice number, invoice date, due date, PO number, currency, " +
  "subtotal, discount, tax, total and every line item across all pages. Dates as YYYY-MM-DD. " +
  "Amounts as plain numbers. Use 0 when there is no discount or tax. Do not include repeated " +
  "table headers, group subtotal rows or rows without an amount as line items.";

const schema = {
  type: "object",
  properties: {
    vendorName: { type: "string" },
    vendorTaxId: { type: "string" },
    invoiceNumber: { type: "string" },
    invoiceDate: { type: "string" },
    dueDate: { type: "string" },
    poNumber: { type: "string" },
    currency: { type: "string" },
    subtotal: { type: "number" },
    discount: { type: "number" },
    tax: { type: "number" },
    total: { type: "number" },
    lineItems: {
      type: "array",
      items: {
        type: "object",
        properties: {
          description: { type: "string" },
          quantity: { type: "number" },
          unitPrice: { type: "number" },
          amount: { type: "number" },
        },
        required: ["description", "amount"],
      },
    },
  },
  required: ["vendorName", "invoiceNumber", "invoiceDate", "total"],
};

type Invoice = {
  subtotal?: number;
  discount?: number;
  tax?: number;
  total?: number;
  lineItems?: { amount: number }[];
};

const cents = (n = 0) => Math.round(n * 100);

function arithmeticHolds(inv: Invoice): boolean {
  const lines = inv.lineItems ?? [];
  const lineSum = lines.reduce((s, li) => s + cents(li.amount), 0);
  const subtotal = cents(inv.subtotal);
  const totalOk =
    Math.abs(subtotal - cents(inv.discount) + cents(inv.tax) - cents(inv.total)) <= 1;
  return inv.total !== undefined && lines.length > 0 && Math.abs(lineSum - subtotal) <= 1 && totalOk;
}

async function extractInvoice(url: string, documentId: string) {
  let result = await client.invoice.extract(
    { url, prompt, schema, model: "auto" },
    { context: { documentId } },
  );
  let credits = result.credits;

  if (!arithmeticHolds(result.data as Invoice)) {
    result = await client.invoice.extract(
      { url, prompt, schema, model: "max" },
      { context: { documentId } },
    );
    credits += result.credits;
  }

  return {
    invoice: result.data as Invoice,
    passed: arithmeticHolds(result.data as Invoice),
    model: result.model,
    pageCount: result.pageCount,
    credits,
  };
}

Anything that comes back with passed: false goes to review. The full validation rule set (dates, currencies, tax rate plausibility, duplicates, vendor master and PO matching) is in How to Validate Extracted Invoice Data.

Designing the review step so it stays small

The goal of review is to handle exceptions, not to re-check everything. A few design choices keep it fast:

  • Send reasons, not just documents. "Lines sum to 4,180.00, subtotal is 4,380.00" points the reviewer at one missing line. "Please check this invoice" means re-reading the whole thing.
  • Show the extracted values next to the PDF, so the reviewer corrects fields instead of typing them.
  • Separate data problems from business problems. Failed arithmetic is a data problem (retry, then correct). A duplicate, an unknown vendor, a changed bank account or a PO mismatch is a business problem that needs a decision, and should go to whoever owns that decision.
  • Record corrections. If reviewers keep fixing the same field for the same vendor, adjust the prompt or add a vendor-specific rule.

Because there is no per-field confidence score in the response, the checks are the routing signal. A useful extra for high-value invoices is a second extraction on a different tier: if both agree on vendor, number, date and total, post it; if not, review it.

Connecting extraction to AP, ERP and reporting

Extraction is step one; the data has to land somewhere without someone babysitting it. Three common paths:

  1. Into the AP or ERP system. Your code (or an integration platform) posts validated invoices through the system's API or an import file and leaves exceptions in a review queue. Keep the PDF and the extracted JSON together so any posted figure can be traced back to the document.
  2. Through no-code automation. PDF Vector's invoice actions are available in Zapier, Make and n8n: a Gmail attachment goes in, a spreadsheet row or an accounting record comes out, with a Code step for the checks. For n8n specifically, see the n8n invoice workflow.
  3. Into a data warehouse. For spend analytics, accruals or audit, load header and line data into tables with lineage columns (request ID, model, credits, source file). The guide to turning financial PDFs into analytics-ready data covers schema design and loading.

If you already use RPA, extraction can take over the reading while the bots keep doing what they are good at: clicking through legacy screens that have no API.

In every case, keep the output in a documented schema you own, so you can change tools later without rewriting everything downstream.

What it costs

Invoice Extract is billed per page: 6 credits on nano, 10 on mini, 14 on pro and 18 on max. auto bills the tier it ran, and at most mini for digital PDFs read without OCR. Requests that end in an error are not charged.

For the four-page logistics invoice:

  • Passing on mini: 4 × 10 = 40 credits.
  • Failing on mini and retried on max: 40 + 4 × 18 = 112 credits.
  • A scan extracted directly on pro: 4 × 14 = 56 credits.

For a month of 400 invoices averaging 1.5 pages (600 pages) on mini, with 5% of invoices (30 pages) retried on max: 600 × 10 + 30 × 18 = 6,540 credits. That is above Basic's 3,000 credits ($25/month) and well within Pro's 100,000 ($97/month). The free plan's 100 credits a month are enough to test with your own invoices. See pricing for annual rates.

Is it a good fit?

FactorGood fitProbably not worth it yet
VolumeEnough invoices that keying them takes real hours each monthA few dozen invoices a month that one person handles comfortably
Vendor varietyMany vendors, layouts and currenciesOne or two vendors with stable layouts
Document mixInvoices plus statements, receipts or reportsA single standardized form
IntegrationSomeone can maintain an API call or a no-code flowNo one to own the workflow
ControlsYou need traceability from posted figures back to documentsLow audit scrutiny

If most of your volume is a handful of vendors with stable layouts, an e-invoicing feed or a supplier portal may serve you better than any extraction. When variety is high, extraction plus validation is usually what removes the keying.

A rollout plan that builds trust

  1. Collect a test set. Take 50 to 100 recent invoices that were already posted, including your hardest vendors, scans and multi-page invoices. Their posted values are your answer key.
  2. Run them through extraction and validation. Compare each field with the posted value, and count how many invoices pass the checks and how many of those were actually correct.
  3. Tune. Adjust the prompt for recurring problems (date formats, discount layouts, what counts as a line), and decide which tier to start at.
  4. Run in shadow mode for a few weeks. Extract every new invoice but keep posting manually; compare results daily.
  5. Turn on automatic posting for invoices that pass every check, starting with low amounts or trusted vendors, and keep the review queue for the rest.
  6. Keep measuring. Track pass rate per vendor and the fields reviewers correct most.

Before you call the API at all, you can see how the engine reads your invoices with the free PDF to Markdown tool, and the accounts payable use case shows where extraction fits in the wider AP process.

FAQ

What is AI invoice data extraction?

It is the use of AI models to read invoices, including scans and multi-page PDFs, and return structured fields such as vendor, invoice number, totals, tax and line items, without a template per vendor.

How accurate is AI invoice extraction?

It depends on your invoices, so measure it on your own: run 50 to 100 already-posted invoices through extraction and compare field by field. Then rely on arithmetic and cross-system checks on every invoice rather than on an average accuracy figure.

Does it handle multi-page invoices with line items on several pages?

Yes. Send all pages in one request so the line items array can cover every page. Check that the line items sum to the subtotal to confirm nothing was dropped or double counted.

What does AI invoice extraction cost with PDF Vector?

6 to 18 credits per page for Invoice Extract, depending on the tier. A two-page invoice on mini costs 2 × 10 = 20 credits.

Do I still need people in the process?

Yes, for exceptions: invoices that fail the checks after a retry, duplicates, new vendors, changed bank details and PO mismatches. The aim is that people decide on exceptions instead of keying every invoice.

Can it read invoices that arrive as photos?

Yes. Scanned PDFs work on mini and above; image files such as PNG and JPG need pro, max or auto. Keep the totals check, since OCR mistakes tend to affect digits.