Skip to content

abhinavm10/bill-extraction-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bill Data Extraction API

Extracts line items from bills/invoices using Google Gemini 1.5 Flash Vision.

Setup

  1. Create virtual environment:
python -m venv venv
venv\Scripts\activate  # Windows
  1. Install dependencies:
pip install -r requirements.txt
  1. Create .env file with your Google AI Studio API key:
GOOGLE_API_KEY=your_key_here
  1. Run the server:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

API Usage

POST /extract-bill-data

{
    "document": "https://example.com/invoice.pdf"
}

Response Format

{
    "is_success": true,
    "token_usage": {
        "total_tokens": 1234,
        "input_tokens": 1000,
        "output_tokens": 234
    },
    "data": {
        "pagewise_line_items": [...],
        "total_item_count": 10
    }
}

Deployment

Option 1: Render (Recommended - Free tier available)

  1. Push code to GitHub
  2. Go to render.com → New Web Service
  3. Connect your GitHub repo
  4. Settings:
    • Build Command: pip install -r requirements.txt
    • Start Command: uvicorn app.main:app --host 0.0.0.0 --port $PORT
    • Environment Variables: Add GOOGLE_API_KEY=your_key_here
  5. Deploy!

Option 2: Railway

  1. Push code to GitHub
  2. Go to railway.app → New Project → Deploy from GitHub
  3. Add environment variable: GOOGLE_API_KEY
  4. Railway auto-detects FastAPI and deploys

Option 3: Fly.io

  1. Install flyctl: iwr https://fly.io/install.ps1 -useb | iex
  2. Login: fly auth login
  3. Initialize: fly launch (in project directory)
  4. Set secret: fly secrets set GOOGLE_API_KEY=your_key_here
  5. Deploy: fly deploy

Option 4: Vercel (Serverless)

  1. Install Vercel CLI: npm i -g vercel
  2. Create vercel.json:
{
  "version": 2,
  "builds": [{"src": "app/main.py", "use": "@vercel/python"}],
  "routes": [{"src": "/(.*)", "dest": "app/main.py"}]
}
  1. Deploy: vercel
  2. Set env var: vercel env add GOOGLE_API_KEY

Note: For all platforms, make sure to set the GOOGLE_API_KEY environment variable in the platform's dashboard.

Releases

Packages

Contributors