Skip to main content

favai

AI Agent Extension for Fava. favai lets you interact with your Beancount ledger through natural language — import transactions, analyze income and expenses, and explore more agent-driven workflows.

Features

  • Import bills — paste bank statement text, upload screenshots or PDFs, and let an LLM agent extract transactions and map them to your ledger accounts
  • Chat with your ledger — ask questions in natural language using BQL queries ("What was my food spend this month?")
  • Multi-turn editing — give feedback to refine the proposed transactions before writing
  • Any LLM provider — OpenAI-compatible or Anthropic-compatible APIs (supports custom endpoints and $ENV_VAR API keys)
  • OCR fallback — PaddleOCR extracts text from bill images for non-vision models (optional)

How it works

favai runs the agent loop directly in your browser using pi-agent-core + pi-ai. The LLM agent is embedded in the extension's JavaScript bundle — no external subprocess, no Node.js dependency at runtime.

Browser (FavaAI.js)
  ├── pi-agent-core Agent (unified: import + chat)
  ├── pi-ai provider → favai llm_proxy → your LLM API
  ├── propose_transactions tool (import) — updates proposal table
  ├── bql_query tool (chat) — queries fava's built-in BQL API
  └── import_confirm → writes entries via fava's existing write path

favai backend (Flask, stateless)
  ├── config (GET/POST) — provider settings
  ├── ingest (POST) — file/text processing (text/image/PDF)
  ├── llm_proxy (POST) — forwards LLM requests with injected API key
  └── import_confirm (POST) — validates and writes entries to ledger

Installation

Prerequisites

  • Python >= 3.12
  • Fava >= 1.30.14
  • An LLM API key (OpenAI, Anthropic, or any compatible endpoint)

Install from PyPI

pip install favai

With OCR fallback for image-based bills:

pip install "favai[ocr]"

Install from source (development)

# Clone the repo
git clone https://github.com/theodoretsui/favai.git
cd favai

# Install Python dependencies
uv sync

# Build the frontend
cd frontend && npm install && npm run build && cd ..

src/favai/FavaAI.js is generated and intentionally not tracked by Git. Release CI builds it before creating the wheel and source distribution, so installing the published package does not require Node.js.

Configure Fava

Add the extension to your Beancount file:

2026-01-01 custom "fava-extension" "favai"

The extension page will appear at /<your-ledger>/extension/FavaAI/.

Optional: OCR support

pip install "favai[ocr]"
# or: uv sync --extra ocr

Usage

1. Configure an LLM provider

Click the gear icon (top-right) and enter:

  • Provider name: any unique name for the endpoint
  • API type: OpenAI Compatible or Anthropic Compatible
  • Base URL: your endpoint (e.g. https://api.openai.com/v1 or a custom proxy)
  • Supported models: one or more model identifiers (e.g. gpt-4o, claude-sonnet-4-6)
  • API Key: a literal key or an $ENV_VAR reference (recommended)

Use Fetch models to load options from the provider's Models API, or type a model identifier directly into the multi-select and press Enter. Add another provider with the + button; delete a configured provider from its dropdown action. A model can be selected above the chat before the first message. The selected model is stored with the session and cannot be changed after that session starts, which keeps multimodal message history compatible with the model that created it.

Provider settings are stored as a list in .favai/config.json. Save writes or replaces only the selected provider. Every saved provider and its selected model list then appears in the new-session model selector.

2. Import bills

In the chat interface, paste text or upload files (.txt, .csv, .png, .jpg, .pdf, etc.) and press Enter. The LLM agent extracts transactions and presents them in an editable table. You can:

  • Edit cells directly in the table
  • Send natural-language feedback ("change this one to Dining")
  • Confirm to write, or discard

3. Chat with your ledger

Type questions like:

  • "What was my food spend last month?"
  • "Show me all transactions to Alipay in July"
  • "How much did I spend on utilities this year?"

The agent translates your questions into BQL queries and summarises the results.

Security

  • API keys are stored next to your Beancount file in .favai/config.json (git-ignored by default)
  • Environment variable references are recommended: $MY_API_KEY
  • The browser never has access to the real API key — LLM requests pass through the backend proxy
  • No file-system or shell access is granted to the LLM agent (only the registered tools)

Development

# Install dependencies
make deps

# Run tests
make test

# Lint
make lint

# Build frontend
make build

# Serve the example ledger
make run

See also AGENTS.md for architecture details and code conventions.

License

favai is licensed under the MIT License.

Metadata

Release files for favai 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for favai 0.2.1
File Size Uploaded
favai-0.2.1.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for favai 0.2.1
File Interpreter ABI Platform
favai-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.9 MB

Release files / favai-0.2.1.tar.gz

Download URL favai-0.2.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
86cb34b0e993e0d8530a6bbbbba8754b7c6e8037d81584682c9684c2a38685cc
BLAKE2b-256 checksum
How to use checksums
c13c10d34cbff22c5e9daa5923243f23fb1f76d24e2682e222de1b69cc94f267
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release files / favai-0.2.1-py3-none-any.whl

Download URL favai-0.2.1-py3-none-any.whl
Size 808.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f231bf8c5bfc6c605319dc0b0410264e02827589d4da193a578ed917a63b741b
BLAKE2b-256 checksum
How to use checksums
d120c52ffbc33b811c422bb7e5473e4857a88d85caf2ed985866e6a970a91015
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page