Skip to main content

Invoice OCR Documentation

Extract structured data from invoices with AI-powered OCR. Supports India GST formats with intelligent reconciliation and validation.

// Upload an invoice
POST /api/ocr-structured-v4
”imageBase64”: ”…”,
“mimeType”: “image/png”

Quick start

Get up and running with Invoice OCR in minutes

1

Install dependencies

Clone the repository and install the required packages.
git clone https://github.com/bnishit/purchase-ocr.git
cd purchase-ocr
npm install
2

Configure environment variables

Copy the example environment file and add your OpenRouter API key.
cp .env.example .env.local
Add your OpenRouter API key to .env.local:
OPENROUTER_API_KEY=your_api_key_here
OPENROUTER_MODEL=openai/gpt-4o-mini
3

Start the development server

Run the Next.js development server and open your browser.
npm run dev
Navigate to http://localhost:3000 and upload your first invoice to extract structured data.

Key features

Everything you need to process invoices with AI

Multiple OCR modes

Raw text extraction, structured MyBillBook schema, and normalized India GST format

Intelligent reconciliation

Automatic validation of totals, taxes, and line items with ₹0.05 tolerance

PDF support

Process both images and PDFs via OpenRouter vision models

Review tool

Debug OCR responses with detailed breakdowns and reconciliation traces

Model comparison

Test multiple AI models side-by-side to find the best accuracy

Explore by topic

Learn how to use Invoice OCR effectively

Uploading invoices

Upload and process invoice images

Processing PDFs

Work with PDF documents

Understanding reconciliation

How the reconciliation engine works

API endpoints

Explore the REST API

Configuration

Set up environment variables

Development

Contribute to the project

Ready to get started?

Follow our quickstart guide to process your first invoice in minutes

View Quickstart Guide

Build docs developers (and LLMs) love