Skip to content
Shipping AI Builds

Should you build your own document processing pipeline?

Generic OCR breaks on messy B2B documents. Here is how to decide when to build a custom extractor.

B2B operations desk with dual monitors showing a PDF packing list side-by-side with structured JSON extraction code
Shreyansh Doshi Founder, Samvara Published Reviewed Read 7 min

What You Need to Know

Build a custom document processing pipeline when you handle over 10,000 messy documents monthly, or when supplier formats change too often for generic OCR templates. Off-the-shelf SaaS works for standard invoices, but custom builds eliminate per-page fees and handle nested B2B tables reliably.

At a Glance

Volume threshold to build
10,000+ documents per month
Primary operational advantage
Zero per-page SaaS markup fees
Core technology shift
Vision LLMs replacing rigid zonal OCR
Common failure point
Chasing 100% automation instead of handling exceptions

Best For

  • Operations directors managing high-volume document triage
  • IT leaders evaluating AI extraction tools
  • Supply chain and freight operators in the US, UK, and Australia

Not For

  • ×Small businesses processing a few dozen standard receipts
  • ×Consumer app developers
  • ×Teams looking for basic template OCR

Key Takeaways

  • Template-based OCR fails in B2B environments because supplier document layouts change constantly.
  • Off-the-shelf SaaS solutions charge high per-page fees that penalize volume growth.
  • Custom AI pipelines use vision LLMs to read unstructured documents without templates.
  • Internal engineering builds usually fail by trying to automate 100% of edge cases instead of building an efficient human review queue.
  • A custom build requires dedicated layers for document classification, data extraction, and deterministic math validation.

Your accounts payable or freight operations desk is likely drowning in PDFs. Every day, suppliers, partners, and carriers email packing lists, commercial invoices, and quotes that your team manually rekeys into an ERP.

You already know this manual process scales poorly. When volume spikes, you throw more administrative headcount at the inbox. The natural instinct is to buy an off-the-shelf Optical Character Recognition (OCR) tool to fix it.

But if you handle complex B2B documents—where line items span multiple pages, nested tables change layout without warning, and harmonized system (HS) codes sit buried in the fine print—standard SaaS tools break. They rely on fixed templates. When a supplier in India adds a new column to their invoice, the template fails, and the document dumps back into a manual review queue.

At a certain operational volume, paying a vendor ten cents a page to fail at edge cases stops making sense. You reach a decision point: keep fighting with rigid off-the-shelf software, or build a custom document processing pipeline using modern large language models (LLMs).

Here is how to make that call, and what actually goes into shipping a custom system.

The problem with off-the-shelf SaaS

Most commercial document extraction software was built on zonal OCR. You draw a box on a screen and tell the software, "The total amount is always in this box."

This works perfectly for standard receipts or highly regulated, uniform tax forms. It completely falls apart in global trade and B2B operations.

A commercial invoice from a manufacturing partner in Europe will look completely different from one generated by a distributor in Australia. Even worse, the same distributor will occasionally update their ERP, changing their output format overnight. If your operations rely on zonal OCR, every layout change forces your IT team to rebuild a template.

Modern SaaS vendors have layered AI on top of this, but you are still locked into their specific extraction logic, their user interface, and their pricing model. If you process 50,000 documents a month, paying a per-page SaaS fee quickly becomes a massive recurring tax on your operations. You are effectively renting a solution that only solves 70% of your problem, leaving your team to manually clean up the remaining 30%.

Why custom AI extraction is different now

Three years ago, building a custom document extraction engine required hiring a team of machine learning engineers to train proprietary models. It was a million-dollar capital expenditure reserved for massive enterprise players.

Today, foundation vision models—like GPT-4o or Claude 3.5 Sonnet—read messy, unstructured documents out of the box. They do not need templates. You pass the model a scanned PDF of a 14-page packing list and prompt it to extract specific fields into a structured JSON payload.

The technical challenge has shifted. You no longer need to train a model to recognize a table. Instead, you need to build the software plumbing that wraps around these models. A custom pipeline gives you complete control over:

  1. Ingestion: Automatically scraping specific inboxes, validating attachments, and stripping out junk signatures.
  2. Routing logic: Deciding whether a document needs a fast, cheap model (like a simple one-page quote) or a heavy, complex model (like a dense multi-page manifest).
  3. Validation: Running math checks on the extracted data before it ever hits your database. Does the line-item total match the subtotal? Does the extracted Purchase Order number actually exist in your NetSuite instance?
  4. The Human-in-the-Loop UI: Giving your operators a custom screen where they only review the fields the AI flagged as low-confidence, rather than reading the entire document.

The math behind the build vs. buy decision

The financial argument for building a custom pipeline hinges on volume and complexity.

If you process 2,000 standard invoices a month, buy an off-the-shelf tool. The engineering cost of a custom build will take years to pay back.

But if you process 50,000 complex supply chain documents a month, the math flips. A standard SaaS tool might charge you $0.15 per page. That is $7,500 a month, or $90,000 a year, in pure variable software costs—not counting the administrative payroll required to fix the edge cases the software misses.

A custom pipeline relies on direct API calls to foundation models. Processing that same document through an API might cost less than a penny. The variable cost approaches zero, while your capital goes into building an asset your company actually owns.

The anatomy of a working custom pipeline

When we build AI builds for operations teams, we break the pipeline into distinct, modular steps. This prevents the system from failing silently and gives operators clear visibility into where a document is in the process.

1. The classification layer

Before you extract data, you need to know what you are looking at. A common operations failure is feeding an email thread directly into an extraction model.

Instead, the first step is a lightweight triage model. It looks at an incoming file and assigns a category: Supplier Invoice, Freight Quote, Bill of Lading, or Junk. If it is junk, the system archives it. If it is a recognized type, it routes to the correct extraction prompt.

2. The extraction and structuring layer

This is where the heavy lifting happens. The system passes the document to a vision LLM with a strict schema constraint. We do not ask the model to "summarize the invoice." We force it to return a machine-readable JSON object containing specific keys: vendor_name, invoice_date, line_items, and total_amount.

3. The business logic validation

AI models hallucinate. They misread a smudged '8' as a '3'. You cannot pipe raw LLM output directly into your ERP.

You must build deterministic business rules to check the model's work. If the system extracts 10 line items that sum to $5,000, but the extracted total says $5,800, the math fails. The system must immediately flag that document for human review. Similarly, if the extracted supplier ID does not exist in your vendor database, the pipeline stops.

4. The exception queue

This is the most critical piece of software in the build. When a document fails validation, it drops into a queue for your operations team.

The UI should show the original PDF on one side of the screen and the extracted data on the other, highlighting exactly which field failed the validation check. The operator corrects the single field, clicks approve, and the structured data moves to the ERP.

Why internal attempts stall out

Many IT departments attempt to build this pipeline internally, only to abandon it after three months. We see why internal AI workflow builds stall before production over and over: teams try to automate 100% of the documents.

They get the system working for 85% of their volume. Then they spend weeks tweaking prompts, chaining models together, and writing complex scripts to capture the last 15% of weird, messy edge cases. The project becomes a money pit of engineering time.

An AI product studio takes a different approach. We aim for 85% automation and build a highly efficient human interface for the remaining 15%. Chasing absolute perfection in AI extraction is a trap. The goal is not zero human involvement; the goal is reducing a five-minute data entry task to a ten-second verification task.

Moving from prototype to live operations

Getting a script to parse ten PDFs on a developer's laptop is easy. Processing thousands of documents a day in a live commercial environment is hard.

When moving an AI POC to production, you have to account for rate limits, API timeouts, and shifting model behaviors. If you rely on OpenAI or Anthropic APIs, those endpoints occasionally go down or throttle your requests. A production-grade custom pipeline requires retry logic, asynchronous processing queues, and fallback models to keep your operations running when an upstream provider has an outage.

Working with an AI product delivery partner shortens these discovery-to-release cycles. Instead of your internal IT team spending months learning the quirks of prompt engineering and JSON validation the hard way, you get a tested, modular architecture deployed directly into your cloud environment.

You own the code, you own the extraction logic, and you stop paying a SaaS vendor a tax on every page your business processes.

Useful tool

Try Samvara's Import/Export Quote-Time Estimator — Hours, cost and capacity from slow quotes.

Quick Comparison

Feature Custom AI Pipeline Off-the-Shelf SaaS OCR
Per-document cost Direct API cost (<$0.01/page) Vendor markup ($0.10 - $0.25/page)
Handling layout changes Adapts automatically via LLM vision Often requires manual template rebuilding
Data Validation logic Fully customizable to your business rules Limited to vendor's predefined rule sets
Upfront implementation Requires initial software build phase Fast initial setup, but scales poorly

Frequently Asked Questions

How much does it cost to process documents with custom AI?
When calling foundation model APIs directly, processing a standard PDF typically costs fractions of a cent per page. This is vastly cheaper than off-the-shelf SaaS tools, which often charge 10 to 15 cents per page.
Do I need to train my own AI model to read invoices?
No. Modern foundation vision models (like GPT-4o or Claude 3.5) read unstructured text out of the box. You just need to build the software infrastructure to prompt them correctly and handle the output.
What happens when the AI makes a mistake extracting data?
A production-grade custom pipeline includes a validation layer that checks the AI's math and cross-references databases. If data fails validation, the system drops the document into a queue for a human operator to review.

Bottom line

Ditch per-page SaaS products if you process non-standard freight or supplier documents at volume. Build a custom extraction pipeline that routes high-confidence matches directly to your ERP, and drops exceptions into a fast human review queue.

How Samvara researches this guide

We write for exhibition organisers and import/export operators in Australia, the UK, Europe, the US and India. Guides favour specific, verifiable operational advice over generic tips — grounded in systems we have shipped, client workflows, and current industry practice. We revisit articles as tooling and regulations change.

Written by

Shreyansh Doshi, Founder of Samvara

Shreyansh Doshi is the founder of Samvara Technologies, a product studio building operator software and SaaS products for exhibition, import/export, travel and fitness businesses in the UK and Australia. He writes about product delivery, operations systems, and where AI does and does not belong in a real workflow.

Keep Reading

Popular in Shipping AI Builds

Guides readers open next

Free tool for this guide

Import/Export Quote-Time Estimator

Hours, cost and capacity from slow quotes — open it in your browser, no signup.

Open tool