npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pandi2352/gemini-ocr

v4.0.0

Published

A lightweight OCR processing wrapper using Google Gemini Vision models.

Readme

🔮 Gemini OCR (@pandi2352/gemini-ocr)

The Next-Gen Document Intelligence Wrapper

npm version TypeScript License AI Powered


⚡ Why Gemini OCR?

Traditional OCR (Tesseract, AWS Textract) gives you just text. Gemini OCR gives you understanding.

| Feature | Description | | :--- | :--- | | 🧠 Deep Understanding | Don't just extract text—understand it. Get summaries, titles, and context. | | 🗺️ Mindmaps | Auto-generate Mermaid.js mindmaps to visualize complex documents. | | 🏎️ Batch Processing | Process standard arrays of files (['path', 'url']) in parallel. | | 🎯 Entity Extraction | Extract specific fields (Dates, Names, IDs) into strict JSON. | | 🌈 Multimodal | Works on PDFs, Images, Word Docs, Audio, and Video. |


📚 Step-by-Step Usage Guide

1. Prerequisites

You need a Google Gemini API Key. Get your API Key here

2. Installation

Install the package in your Node.js project:

npm install @pandi2352/gemini-ocr

3. Basic Usage (Text Extraction)

Create a file (e.g., index.ts) and add the following. This works for locally stored files or URLs.

import { processOCR } from '@pandi2352/gemini-ocr';

async function main() {
  const results = await processOCR({
    // Input can be a single file string or an array
    input: ['./my-document.pdf'], 
    apiKey: process.env.GEMINI_API_KEY
  });

  console.log(results[0].extractedText);
}

main();

4. Batch Processing (Multiple Files)

Pass an array of file paths or URLs. They are processed in parallel.

const results = await processOCR({
  input: [
    './invoice_january.pdf',
    'https://example.com/receipt.jpg',
    './meeting_notes.docx'
  ],
  apiKey: process.env.GEMINI_API_KEY,
  summarize: true // Optional: Get summaries for all
});

results.forEach((doc, index) => {
  if (doc.status === 'success') {
    console.log(`File ${index + 1}: ${doc.summary}`);
  }
});

5. Advanced Intelligence (Mindmaps & Entities)

Unlock the full power of AI by enabling specific flags.

const [result] = await processOCR({
  input: ['./complex_contract.pdf'],
  apiKey: process.env.GEMINI_API_KEY,
  
  // Enable Advanced Features
  mindmap: true,        // Generates Mermaid.js visualization
  extractEntities: true, // Extracts JSON data
  entitySchema: ['Contract Value', 'Start Date', 'Parties Involved'] // Optional custom fields
});

// 1. Get the Mindmap
console.log('Mindmap Code:', result.mindmap);

// 2. Get Structured Data
console.log('Extracted Data:', result.entityResult);
/* Output:
{
  "contract_value": "$50,000",
  "start_date": "2024-01-01",
  "parties_involved": "Company A, Vendor B"
}
*/

### 6. Realtime Progress Feedback
Get granular updates on the processing stages.

```typescript
await processOCR({
  input: ['./large_document.pdf'],
  apiKey: process.env.GEMINI_API_KEY,
  
  onProgress: (stage, message) => {
    // stage: 'upload' | 'generate_text' | 'enrich' | 'complete'
    console.log(`[${stage}]: ${message}`);
  }
});

🛠️ Configuration Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | input | Array<string \| Buffer \| Object> | Required | Array of file paths, URLs, Buffers, or Base64 strings. | | apiKey | string | Required | Your Google Gemini API Key. | | model | string | gemini-1.5-flash | The AI model (use gemini-1.5-flash-8b for speed). | | summarize | boolean | false | Generate metadata (title, desc, thumbnail). | | mindmap | boolean | false | Generate Mermaid.js syntax for visual mapping. | | extractEntities| boolean | false | Enable structured field extraction. | | entitySchema | string[] | auto | Custom fields to extract (optional). | | onProgress | (stage, userMsg) => void | undefined | Callback for realtime progress updates. |


🤝 Contributing

We love contributions! Please feel free to submit a Pull Request.

  1. Fork it
  2. Create your feature branch (git checkout -b feature/cool-feature)
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request