receipt-ocr
Extract structured data from receipt images using Gemini AI.
Features
- 📷 Extract date, amount, vendor, category from receipt images
- 🚀 Fast and cheap with Gemini Flash
- 🎯 ~95% accuracy on common receipt formats
- 🔧 CLI and Python API
Installation
pip install receipt-ocr
Quick Start
CLI
# Set API key
export GEMINI_API_KEY=your_api_key
# Extract from image
receipt-ocr receipt.jpg
# Pretty print
receipt-ocr receipt.jpg --pretty
# From URL
receipt-ocr https://example.com/receipt.jpg
Output:
{
"receipt_date": "2025-01-15",
"amount": 4599,
"amount_dollars": 45.99,
"category": 0,
"category_name": "grocery",
"vendor_name": "Whole Foods Market",
"payment_method": 0
}
Python API
from receipt_ocr import extract, set_api_key
# Set API key (or use GEMINI_API_KEY env var)
set_api_key("your_api_key")
# Extract from file
result = extract("receipt.jpg")
print(result.amount_dollars) # 45.99
print(result.vendor_name) # "Whole Foods Market"
print(result.receipt_date) # "2025-01-15"
# Extract from URL
result = extract("https://example.com/receipt.jpg")
# Extract from bytes
with open("receipt.jpg", "rb") as f:
result = extract(f.read())
# With date context (helps infer year)
result = extract("receipt.jpg", reference_date="2025-01")
Output Fields
| Field | Type | Description |
|---|---|---|
receipt_date |
str | Date in YYYY-MM-DD format |
amount |
int | Total amount in cents |
amount_dollars |
float | Total amount in dollars |
category |
int | 0=grocery, 1=gas station, 2=other |
category_name |
str | Human-readable category |
vendor_name |
str | Merchant/store name |
payment_method |
int | 0=credit, 1=debit, null=unknown |
CLI Options
receipt-ocr [OPTIONS] IMAGE
Arguments:
IMAGE Path to receipt image or URL
Options:
--api-key TEXT Gemini API key
--reference-date TEXT Expected date (YYYY-MM) for year inference
--model TEXT Gemini model (default: gemini-2.0-flash)
--raw Include raw AI response
--pretty Pretty print JSON
Accuracy
Tested on ~1000 receipts:
| Field | Accuracy |
|---|---|
| Amount | ~98% |
| Date | ~95% |
| Vendor | ~90% |
Tips for better accuracy:
- Clear, well-lit photos
- Include the total amount in frame
- Avoid heavy shadows/glare
Cost
Using Gemini Flash: ~$0.001 per receipt
License
MIT
Metadata
Release files for gemini-receipt-ocr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gemini_receipt_ocr-0.1.0.tar.gz | 6.5 kB | Without provenance | Details for gemini_receipt_ocr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gemini_receipt_ocr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gemini_receipt_ocr-0.1.0-py3-none-any.whl |
Total release size: 14.3 kB
Release files / gemini_receipt_ocr-0.1.0.tar.gz
| Download URL | gemini_receipt_ocr-0.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8478a4592b00b6c33cfb95d96eac339d1c39fb4e793331e124e98af083d85bf9
|
|
BLAKE2b-256 checksum How to use checksums |
dac4e329750a985b3289c156c0a1da848387c854160a85cd1c1d5d09bf230913
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / gemini_receipt_ocr-0.1.0-py3-none-any.whl
| Download URL | gemini_receipt_ocr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82ea689c2d683c39a6496418420a0ccb1d88959c582ab23aab20f8fc2e66cb78
|
|
BLAKE2b-256 checksum How to use checksums |
5729253d9c2bf14d32682c96b641d7943f9461438cb11922492707d1da1f6ae9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for gemini-receipt-ocr 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.