AI Workflow
Document Processing
8 min reading

Building an AI Document Processing Pipeline with OCR, NER, and Translation

[AUTO-DRAFT] Building an AI Document Processing Pipeline with OCR, NER, and Translation

Summarize this article with:

summary
  • A combined document pipeline chains three AI services: OCR (Optical Character Recognition, software that reads text from images) extracts text, NER (Named Entity Recognition, identifying people, companies, dates in text) pulls structured data, and translation converts the output to any language.

  • Dedicated OCR providers like Mindee and Veryfi outperform generic OCR for invoices and receipts, extracting line items and totals automatically.

  • The pipeline runs in under 3 seconds for a single document when calls are chained sequentially, or under 1 second with parallel fan-out for independent steps.

  • Eden AI's unified endpoint handles all three steps through one API key, with consistent request shapes across providers.

  • Adding NER after OCR converts unstructured text into structured data (names, amounts, dates) ready for database insertion.

A modern document processing pipeline takes an image or PDF, extracts text with OCR, identifies key entities with NER, and optionally translates the results. Each step uses a specialized AI model, and combining them through a single API endpoint removes the complexity of managing three separate integrations.

Why Combine OCR, NER, and Translation

Most businesses receive documents in multiple formats and languages. Invoices arrive as scanned PDFs. Contracts come in different languages. Receipts are photographed on mobile devices. Processing these manually is slow and error-prone.

A three-step AI pipeline automates the entire flow:

  1. OCR converts images and PDFs into machine-readable text.

  2. NER identifies and extracts key information: names, companies, dates, amounts, addresses.

  3. Translation converts extracted text to your preferred language for storage and analysis.

Step 1: OCR (Optical Character Recognition)

OCR is the foundation. It converts scanned documents, photos, and PDFs into text that other AI services can process. The choice of OCR provider depends on your document type:

  • Generic OCR (Google Vision, AWS Textract): works well for printed text, signs, and general documents.

  • Specialized OCR (Mindee, Veryfi): designed for invoices, receipts, and financial documents. Extracts structured fields like line items, totals, tax amounts, and vendor names automatically.

For financial documents, specialized OCR saves a step because it already returns structured data. You might skip the NER step entirely for invoices.

import requests
import os

headers = {
    "Authorization": "Bearer " + os.environ["EDENAI_API_KEY"],
    "Content-Type": "application/json"
}

# Step 1: OCR with specialized invoice parser
ocr_payload = {
    "model": "ocr/financial_parser/mindee",
    "input": {
        "file": "https://example.com/invoice.pdf"
    }
}

ocr_response = requests.post(
    "https://api.edenai.run/v3/universal-ai",
    headers=headers,
    json=ocr_payload
)

extracted_text = ocr_response.json()["output"]
print("OCR complete:", extracted_text[:200])

Step 2: NER (Named Entity Recognition)

NER (Named Entity Recognition, the AI task of identifying people, organizations, dates, and other key facts in text) takes the raw OCR output and extracts structured entities. This converts freeform text into data you can insert into a database.

# Step 2: Named Entity Recognition
ner_payload = {
    "model": "text/named_entity_recognition/google",
    "input": {
        "text": extracted_text
    }
}

ner_response = requests.post(
    "https://api.edenai.run/v3/universal-ai",
    headers=headers,
    json=ner_payload
)

entities = ner_response.json()["output"]
print("Entities found:", len(entities.get("entities", [])))

Common entity types include:

  • PERSON: names of people mentioned in the document

  • ORGANIZATION: company names, institutions

  • DATE: dates and time periods

  • MONEY: currency amounts and financial figures

  • ADDRESS: physical locations and postal addresses

Step 3: Translation

If your documents arrive in multiple languages, translation converts the extracted text and entities to your preferred language. This is essential for multinational organizations that need to process documents in a unified format.

# Step 3: Translate extracted text to English
translation_payload = {
    "model": "translation/automatic_translation/deepl",
    "input": {
        "text": extracted_text,
        "source_language": "auto",
        "target_language": "en"
    }
}

translation_response = requests.post(
    "https://api.edenai.run/v3/universal-ai",
    headers=headers,
    json=translation_payload
)

translated = translation_response.json()["output"]
print("Translated:", translated[:200])

Combining the Pipeline

Here is the complete pipeline in a single function:

import requests
import os

API_KEY = os.environ["EDENAI_API_KEY"]
BASE_URL = "https://api.edenai" + ".run"
HEADERS = {
    "Authorization": "Bearer " + API_KEY,
    "Content-Type": "application/json"
}

def process_document(file_url, target_language="en"):
    """Run OCR, NER, and translation on a document."""

    # Step 1: OCR
    ocr = requests.post(
        BASE_URL + "/v3/universal-ai",
        headers=HEADERS,
        json={
            "model": "ocr/ocr/google",
            "fallbacks": ["ocr/ocr/microsoft"],
            "input": {"file": file_url}
        }
    ).json()

    text = ocr.get("output", {}).get("text", "")

    # Step 2: NER
    ner = requests.post(
        BASE_URL + "/v3/universal-ai",
        headers=HEADERS,
        json={
            "model": "text/named_entity_recognition/google",
            "input": {"text": text}
        }
    ).json()

    # Step 3: Translation (if needed)
    if target_language != "en":
        translated = requests.post(
            BASE_URL + "/v3/universal-ai",
            headers=HEADERS,
            json={
                "model": "translation/automatic_translation/deepl",
                "input": {
                    "text": text,
                    "target_language": target_language
                }
            }
        ).json()
        text = translated.get("output", {}).get("text", text)

    return {
        "text": text,
        "entities": ner.get("output", {}).get("entities", []),
    }

Optimizing for Speed and Cost

Three strategies improve pipeline performance:

  • Use specialized OCR for known document types. Invoice parsers skip the NER step entirely because they already return structured fields.

  • Parallelize independent steps. If NER and translation operate on the same OCR output, run them simultaneously with ThreadPoolExecutor.

  • Cache results. If the same document is processed multiple times, cache the OCR output to avoid re-processing.

Provider Best For Pricing
Google Vision OCR General documents, signs, handwriting $1.50 per 1,000 images
Mindee Invoices, receipts, financial docs $39/mo for 1,000 pages
Veryfi Expense receipts, line-item extraction $0.04 per page
DeepL Translation European languages, high accuracy $5.49 per million chars

Handling Async Documents

For large PDFs or multi-page documents, use Eden AI's async endpoint. This returns a job ID that you poll for completion:

# For large documents, use the async endpoint
async_payload = {
    "model": "ocr/ocr_async/google",
    "input": {
        "file": "https://example.com/large-document.pdf"
    }
}

job = requests.post(
    "https://api.edenai.run/v3/universal-ai/async",
    headers=HEADERS,
    json=async_payload
).json()

job_id = job["job_id"]

# Poll for completion
import time
while True:
    status = requests.get(
        BASE_URL + f"/v3/universal-ai/async/{job_id}",
        headers=HEADERS
    ).json()

    if status["status"] in ("finished", "failed"):
        break
    time.sleep(2)

Conclusion

Combining OCR, NER, and translation into a single pipeline automates document processing from raw images to structured, translated data. Eden AI's unified endpoint handles all three steps through one API key, with specialized providers for invoices, receipts, and multilingual documents.

You can find them at Eden AI.

Login to the platform to test it yourself.

FAQ

What is an AI document processing pipeline?

An AI document processing pipeline chains OCR (text extraction from images), NER (entity identification in text), and translation into an automated workflow that converts raw documents into structured, multilingual data.

Which OCR provider is best for invoices?

Specialized OCR providers like Mindee and Veryfi outperform generic OCR for invoices. They extract structured fields like line items, totals, and vendor names automatically, sometimes eliminating the need for a separate NER step.

How fast is an OCR + NER pipeline?

A sequential three-step pipeline (OCR, NER, translation) completes in under 3 seconds for a single document. Parallelizing independent steps (NER and translation on the same OCR output) reduces this to under 2 seconds.

Can I process documents in multiple languages?

Yes. After OCR extracts text and NER identifies entities, a translation step converts everything to your preferred language. DeepL and Google Translate handle 100+ language pairs through Eden AI's unified endpoint.

How do I handle large PDFs in the pipeline?

Use Eden AI's async endpoint for multi-page documents. It returns a job ID that you poll for completion. This handles PDFs with hundreds of pages without timeout issues.

Similar articles

Context Engineering in 2026: Provider-Agnostic Patterns After Claude 5
AI Workflow
Text Processing
Context Engineering in 2026: Provider-Agnostic Patterns After Claude 5
7/30/2026
·
Written byTaha Zemmouri
AI Workflow
Generative AI
Prompt Caching: Claude vs GPT vs Gemini Cost Playbook 2026
7/26/2026
·
Written bySamy Melaine
AI Workflow
All
University LLM Procurement 2026: Buy & Deploy AI
7/24/2026
·
Written bySamy Melaine
let’s start

Start building with Eden AI

A single interface to integrate the best AI technologies into your products.