Skip to content

Extract JSONs from PDFs using latest Google Gemini flash model

License

Notifications You must be signed in to change notification settings

maurycy/gemini-json-ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemini JSON OCR

Gemini JSON OCR is a proof of concept showing how easy it is to use the latest Google Gemini to extract structured JSONs from documents.

Usage

$ export GOOGLE_API_KEY=<get your API key at https://aistudio.google.com/app/apikey>
$ uv run scan.py /Users/maurycy/Desktop/test
INFO:root:Processing file: MX-C304W_16122024_143019.pdf
Results for MX-C304W_16122024_143019.pdf have been written to /Users/maurycy/Desktop/test/MX-C304W_16122024_143019.pdf.json

Resulting in a JSON, such as:

{
  "waybill": {
    "scac": "SEAU",
    "booking_no": "4803804131",
    "bl_no": "4803804131",
    "vessel": "MERIDIAN",
    "containers": [ "TLLU5242619", "MSKU829454" ]
  }
}

Getting Started

Make sure that you've got uv installed:

# macOS
brew install uv

(No need to install Python etc. uv will take care of that!)

Advanced usage

The prompt is in the prompt.txt.

Supported environment variables:

  • GEMINI_MODEL, by default gemini-2.0-flash-exp
  • GOOGLE_API_KEY, to be retrieved from Google AI Studio

About

Extract JSONs from PDFs using latest Google Gemini flash model

Topics

Resources

License

Stars

Watchers

Forks

Languages