apyhub
Document intelligence · Ocr

One API for Every OCR Job: How a Document Intelligence Engine Routes Each Page to the Right Model

01What is a document intelligence engine, in simple terms?

You send your documents to one API endpoint. The engine looks at every page, sends it to the OCR or AI model that reads it best for the lowest cost, checks the result, and gives you back clean, structured data.

Typed pages go to a cheap, fast reader. Faxes, tables and handwriting go to stronger models. You never have to choose between OCR vendors, connect to five of them, or decide page by page which one to call. The engine does that behind the endpoint.

This post is for teams who need data out of a lot of PDFs: claims, medical records, loan files, invoices, contracts or CVs. To show how the decision usually plays out, we'll follow one team through it.

Talk to us about your documents →

02How does an OCR project usually start?

Picture a product team at an insurance software company. Their customers upload claim packets: claim forms, repair estimates, medical reports, photos of receipts and letters. Each packet runs from 40 to 300 pages. The product manager's request is simple: "Pull the policy number, dates, amounts and diagnosis from every packet, so adjusters stop typing them in."

The first version is a mini project: 1,000 packets for a pilot customer. If it works, it becomes a big project: every customer, about 50,000 packets a month, which is several million pages.

The team lead asks the obvious first question.

03Which OCR should we use?

The team spends a week testing what's out there. The options fall into five groups.

Open-source OCR engines

Tesseract and PaddleOCR run on your own servers.

  • Good: free to use, fast on clean typed pages, and data stays with you.
  • Hard: weaker on faxes, handwriting and complex tables. You run the servers and tune them yourself.

Cloud document AI services

Amazon Textract, Azure AI Document Intelligence and Google Document AI.

  • Good: strong on tables and forms, with prebuilt extractors for common documents such as invoices and IDs, and they scale easily.
  • Hard: priced per page, with big jumps between plain text and forms. You're tied to one cloud's models and regions.

Newer OCR models

Models built for documents, such as Mistral OCR, read complex layouts and return Markdown.

  • Good: strong on mixed layouts and structured output.
  • Hard: another vendor, another contract, another set of limits.

Vision-language models

General AI models such as GPT, Gemini and Claude can read a page image and answer questions about it.

  • Good: the strongest option for handwriting, charts and messy pages.
  • Hard: the most expensive per page, slower, and they need checks so they don't return confident wrong answers.

Document processing platforms

Packaged intelligent document processing (IDP) software, such as ABBYY.

  • Good: templates, review screens and workflows for business teams.
  • Hard: usually priced per document or seat, and slower to build into your own product.

By Friday, the team has a spreadsheet and a problem.

04Why can't we just pick one OCR?

Because no single option wins on every page.

The open-source engine reads the typed claim forms well and cheaply, but stumbles on the faxed medical reports. The cloud service handles the repair estimate tables, but costs far more per page. The vision model reads the doctor's handwriting, but using it on every page would blow the budget.

The price gaps are large. Amazon Textract charges $1.50 per 1,000 pages to read plain text and $50 per 1,000 pages to analyse forms (Amazon Textract pricing, US West (Oregon), first million pages). On the ApyHub catalog, running OCR on one page costs 80 times more than reading the text of an entire digital PDF.

And many pages don't need OCR at all. Plenty of the claim packets are digital PDFs with the text already inside.

At a few million pages a month, sending every page to the strongest model means paying top price for pages a cheap reader would handle. Sending every page to the cheapest one means missing the diagnosis on page 212.

So the team asks the next question.

05What if we use the right OCR for each page?

That's routing. The team sketches it on a whiteboard:

Page typeBest fitCost
Digital page with textRead the text straight from the fileLowest
Clean typed scanFast OCR engineLow
Poor scan or faxClean up the image, then a stronger OCR modelMedium
Tables and formsLayout modelHigh
Handwriting, chartsVision modelHighest
Blank pages, cover sheetsSkipZero

Take a 400-page packet where 300 pages are digital. Reading those 300 from the file and sending only 100 to OCR cuts OCR spend on that packet by about 75%. Add stronger models only where they're needed, and the cost per packet drops further without losing accuracy.

The idea is easy. Then the tech lead lists what it takes to build.

06What does it take to build a router yourself?

  • Contracts and security reviews with every OCR and AI vendor you plan to use.
  • Page analysis: detect digital pages, scan quality, tables, handwriting and blank pages.
  • Routing rules for cost, accuracy, and which models may see sensitive data.
  • Checks: compare models, validate dates, codes and totals, and score confidence.
  • A review path for pages the models aren't sure about.
  • Provenance: record the page and position behind every value, for auditors.
  • Scale: queues, parallel workers, retries, and every vendor's rate limits.
  • Upkeep: test and swap in new models as they get better and cheaper.

The estimate comes back at several months for a small team, and someone to run it after that. The team lead asks the question that matters most.

07Can we get the routing without building it?

Yes. That's what the ApyHub document intelligence engine does.

The team calls one API endpoint. Behind it, the engine routes every page to the best fit for the job: the text layer for digital pages, a fast OCR engine for clean scans, a stronger model for faxes, a layout model for tables, a vision model for handwriting. Which one is "best" depends on the rules the team sets:

  • Cheapest that's good enough: the lowest-cost model that meets the accuracy threshold for that page type.
  • Most accurate: escalate to a stronger model when two models disagree or a score drops.
  • Compliant: send sensitive data only to models that are allowed to see it, such as local models or providers under the team's own agreements.

Every page goes through the same six steps:

  1. Analyse the page type, layout and scan quality.
  2. Route it to the right model.
  3. Extract in parallel, so a 300-page packet finishes in minutes.
  4. Check the results against each other and validate dates, codes and totals.
  5. Score every page and field with a confidence value.
  6. Structure the output as JSON, with every field linked to its page and position.

An illustrative result for one field:

· json
{
  "field": "date_of_service",
  "value": "2026-03-12",
  "source": { "page": 212, "box": [88, 410, 512, 436] },
  "confidence": 0.993
}

Pages below the threshold go where the team decides: a stronger model, an adjuster's review queue, or a hold. When a better or cheaper OCR model comes out, it can be added to the routing without changing the team's integration.

The models underneath are the same kind the team tested in week one. The difference is that they no longer have to pick one, connect to each, or maintain the logic between them.

See the APIs in the Document Intelligence Kit →

08Where will our documents be processed?

Before anything goes live, the team's security lead asks this. Claim packets hold medical and financial data, so the answer decides whether the project can go ahead. ApyHub runs the engine in three ways.

Hosted in our EU, US or India region

The engine runs on ApyHub's infrastructure, in the region you choose, and your files are processed and stored there.

  • EU region: for companies serving European customers under GDPR.
  • US region: for US customers and data, with lower latency for US products.
  • India region: for data that should stay in India, for example under India's Digital Personal Data Protection Act, 2023.
  • Fastest start: nothing to install. You call one endpoint and can be live in days.

Best for: the mini project, a pilot, or any team that wants to start fast with data kept in one of those regions.

Dedicated hosting

The engine runs in an environment ApyHub operates for your company alone, in the region you choose.

  • Isolation: no shared infrastructure with other customers, which makes security reviews simpler.
  • Capacity: compute and limits sized for your volume and your busiest hours.
  • Your settings: your choice of models, routing rules, data retention and update timing.
  • Fully managed: ApyHub runs, monitors and updates it.

Best for: the big project, high volumes and regulated teams that want isolation without running infrastructure.

Self-hosted on your infrastructure

The engine runs inside your own environment: your Kubernetes cluster on EKS, AKS or GKE, or your own data centre.

  • Your data stays with you: documents, text and content never reach ApyHub. Usage is metered by page count only.
  • Strict rules: suited to health records under HIPAA, banking data and government records.
  • Your models and contracts: run local models on your own GPUs, or use your own accounts with providers such as Mistral, Gemini, Azure or AWS.
  • Your controls: your network, your keys in your own secrets manager, your audit logs.

Best for: healthcare, banking, insurance, government, and any company whose policy says documents stay inside.

Which hosting option fits?

Hosted regionDedicated hostingSelf-hosted
Time to startDaysWeeksWeeks
Where data is processedEU, US or India regionYour own ApyHub environmentYour infrastructure
Shared infrastructureYesNoNo
Who runs itApyHubApyHubYour team, with ApyHub support
ModelsApyHub catalogCatalog or your ownYour own, local or cloud

Many teams start hosted for the pilot and move to dedicated or self-hosted for production, with the same integration.

Ask us which hosting option fits your data →

09How does a team get started?

For our insurance team, the path is three steps:

  1. A 30-minute assessment. We look at their document types, volumes, page mix and current costs, using their own numbers.
  2. A proof of concept on their own documents. A few hundred packets, hard cases included. They get accuracy per document type, cost per 1,000 pages for each model and for the routed mix, and how many pages would need review.
  3. Deployment where they need it: a hosted region for the pilot, then dedicated or self-hosted for the big rollout.

We set accuracy targets after testing on your documents, because accuracy depends on your page mix and scan quality. If the engine won't save you much, we'll tell you.

Book your 30-minute assessment →

10Is a document intelligence engine right for your team?

It's a good fit if:

  • You process thousands of documents a month, with tens or hundreds of pages each.
  • Your files mix digital pages, scans, faxes, tables or handwriting.
  • OCR is becoming a noticeable line on your cloud bill.
  • Security asks where documents go, and the answer matters.

If you have one simple document type at low volume, start with a single API from the Document Intelligence Kit, such as the Extract Invoice Data API, the Resume Parser API or the Image & PDF OCR to Markdown API. You can try each one free on its page.

The engine also works with the rest of the ApyHub kits: the Ingestion Kit to split and convert files, the Safety Kit to anonymise data before it's shared, and the Verification Kit to check IDs and bank details you extract. Every service is verified before it's listed and certified against GDPR, SOC 2 and ISO 27001, under one contract and one DPA.

Talk to us about your document volumes →

11FAQ

What is a document intelligence engine?

One API endpoint that turns documents such as claims, medical records, loan files and invoices into structured data. It decides which OCR or AI model reads each page, checks and scores the results, and links every field to its source page.

Which OCR is the best?

It depends on the page. Open-source engines like Tesseract are cheap and good on clean typed pages. Cloud services like Amazon Textract and Azure AI Document Intelligence are strong on tables and forms. Vision models are best on handwriting. A document intelligence engine uses each one where it fits.

How does routing cut OCR costs?

Digital pages are read straight from the file, and only scans go to OCR. Expensive models are used only for faxes, tables, charts and handwriting. On a file where three quarters of the pages are digital, OCR spend drops by about 75%.

Do I need to integrate with several OCR vendors?

No. You call one ApyHub endpoint, and the engine handles the models behind it. New models can be added to the routing without changing your integration.

Where can the ApyHub engine run?

In ApyHub's EU, US or India region, on dedicated hosting run by ApyHub for your company alone, or self-hosted on your own Kubernetes or in your own data centre.

Does our data reach ApyHub if we self-host?

No. When self-hosted, documents, text and content stay in your environment. ApyHub only receives page counts for metering.

Can we use our own models?

Yes. The engine works with local open-source models, open-weight models on your GPUs, and your own accounts with cloud model providers.

What happens to pages the engine isn't sure about?

You choose: re-run them with a stronger model, send them to human review with the score and the original page, or hold them in your own queue.

How can I test the document APIs first?

Use the "Try it" panel on each API's page in the Document Intelligence Kit, send requests with curl, or save them in Voiden or Postman and run them on your own sample files. You can also ask an AI assistant connected to ApyHub MCP to run them.

12About ApyHub

ApyHub runs a catalog of ready-made APIs and is the trusted operational layer between your application and the services it depends on, so your team builds and maintains less of its own code and ships faster. One subscription covers the whole catalog of over 1,500 endpoints and capabilities, and it keeps growing. Every service is verified before it is listed and carries machine-readable certification covering GDPR, SOC 2 and ISO 27001. Every endpoint is MCP-ready by default. ApyHub runs dedicated EU, US and India regions and serves more than 65,000 developer workspaces every month. Start on the free tier with no card, or publish your own API on ApyHub.

13Sources