Automatically classify and organize Gmail emails using LLM-powered categorization. Queries Gmail for unlabelled emails, classifies them in batches, applies labels, and archives noise categories.
- Queries Gmail for emails missing all category labels (stateless - no local tracking)
- Sends batches of 20 emails to an LLM for classification
- Applies the corresponding Gmail label to each email
- Archives noise categories (junk, newsletter, purchases, events) out of inbox
Categories are defined in taxonomy.yaml and are easy to modify.
uv syncCopy .env.example to .env and fill in:
GOOGLE_CLIENT_ID=... # Google OAuth app credentials
GOOGLE_CLIENT_SECRET=...
OPENROUTER_API_KEY=... # openrouter.ai API key
OPENROUTER_MODEL=google/gemini-2.0-flash-001
Run OAuth (one-time, opens browser):
uv run python main.py authuv run python main.py runClassifies all emails that don't yet have a category label. Safe to run repeatedly - only processes new/unlabelled emails.
docker compose upRequires token.json to exist (run auth locally first).
Edit taxonomy.yaml to add/remove/modify categories:
categories:
- name: junk
description: any pure spam, scam, marketing, or promotion or other noise
archive: trueEach category becomes a Gmail label. Set archive: true to auto-remove from inbox.