ReceiptDB by Counterfoil Labs

Get started

Getting started

From an empty machine to an answer with a receipt.

About 10 minutes. You need Python 3.12+ and Docker.

1. Install

python3 -m venv .venv && . .venv/bin/activate
pip install "receiptdb[live,server,client,pdf,office]==1.0.0rc1"
receipt --version

live adds the local embedding model (BAAI/bge-small-en-v1.5, downloaded on first use) and the Anthropic SDK; pdf adds PDF text extraction, and office adds Word and PowerPoint. For just the Python library, pip install receiptdb==1.0.0rc1 is enough.

pip installs the latest compatible dependencies. The container images pin the exact versions from the repository's uv.lock, as a clone's make install does.

2. Start PostgreSQL

ReceiptDB runs on PostgreSQL with the pgvector extension. For a local trial:

docker run -d --name receiptdb-postgres --shm-size=1g -p 127.0.0.1:54329:5432 \
  -e POSTGRES_USER=receipt -e POSTGRES_PASSWORD=receipt -e POSTGRES_DB=receipt \
  pgvector/pgvector:pg17

That matches ReceiptDB's default connection string, so there's nothing to configure. For your own database, set RECEIPTDB_DSN (see configuration.md). If you ran the README's make demo, its database is already this one, on the same port: skip this step.

3. Ingest your documents, then ask

receipt ingest ./my-docs --trust verified --license internal
export ANTHROPIC_API_KEY=...   # ask: Claude by default, or RECEIPTDB_MODEL=ollama:llama3.3 (no key); search needs none
receipt ask "What does our travel policy say about economy upgrades?"

ask prints the answer, the sources it used, a grounding line (any sentence its sources don't support) and the answer's receipt ID. receipt explain <id> shows the full lineage. Then take the tour: short scenarios showing what the receipts are for.

Supported files: Word (.docx) and PowerPoint (.pptx), PDF (the text layer), Markdown, text, reStructuredText, CSV, JSON, HTML, XML and YAML. Hidden files and folders are skipped, and so is a symbolic link that leads out of the directory. A file with more than one name (a hard link) is skipped with the reason, since another of its names may be outside the directory; --follow-hard-links reads it, and so does naming the file itself. Re-running ingest is safe: unchanged files are skipped.

Nothing is trusted by assumption, your own files included: what receipt ingest reads is labelled unknown-provenance, and receipt explain shows [unknown-provenance] on it, even with --trust verified. Trust and licence say what the content is; the label says nobody has yet vouched for where it came from. Search and answers use the files as usual (a search policy with allow_unknown_provenance: false leaves them out). Once you have confirmed a folder's origin, say so in one logged step: receipt relabel --prefix file:///path/to/my-docs/ --labels '{"unknown_provenance": false}' --reason "our own handbook" (the prefix is the folder's absolute path as receipt explain prints it).

4. The HTTP API

For services in other languages, or a shared deployment, run the API with its database from the quick-start kit, deploy/quickstart in the repository. The kit's database takes port 54329, the one step 2's container holds, so stop that container first (and, if you ran the README's make demo, its database: make down in that clone):

docker stop receiptdb-postgres 2>/dev/null || true   # step 2's database, if you made it; `docker start` brings it back
git clone https://github.com/counterfoillabs/receiptdb
cd receiptdb/deploy/quickstart
./setup.sh                       # writes .env with a random API key and database password
docker compose up -d --wait
curl -s http://127.0.0.1:8321/health

To keep step 2's database running beside the kit instead, add RECEIPTDB_PG_PORT=54330 to .env before docker compose up. The kit's database starts empty, with its own password; to point the CLI at it, set RECEIPTDB_DSN="postgresql://receipt:$(grep ^POSTGRES_PASSWORD .env | cut -d= -f2)@127.0.0.1:54329/receipt" (with the port you chose).

The API reference is at http://127.0.0.1:8321/docs. Clients: receiptdb.client.ReceiptClient (Python) and @receiptdb/client (TypeScript).

5. Connect your agent

The API serves an MCP server at /mcp (streamable HTTP) as soon as it has an embedder for queries: add RECEIPTDB_EMBED_MODEL to deploy/quickstart/.env (ollama:nomic-embed-text with RECEIPTDB_EMBED_BASE_URL=http://host.docker.internal:11434/v1 uses a local Ollama with no extra install), and RECEIPTDB_MCP_PRINCIPALS for who the agent searches as. The agent authenticates with your API key and gets search, explain, record_answer and impact_of_retracting; every answer it records is checked against what it may read.

Ollama on Linux. Installed on the machine itself, Ollama listens on 127.0.0.1 only, which the kit's container can't reach: the agent's search then answers EmbedderUnavailable. Have it listen on every address: sudo systemctl edit ollama, add Environment="OLLAMA_HOST=0.0.0.0" under [Service], then sudo systemctl restart ollama. That opens port 11434 to the machine's network as well, so keep it behind the firewall. Docker Desktop (macOS and Windows) needs none of this.

The model behind the agent is yours; ReceiptDB only needs to know where retrieved content goes (RECEIPTDB_MCP_DESTINATION, e.g. anthropic, openai or local) so egress labels are honoured.

6. In your own app

from receiptdb.integrations.langchain import ReceiptVectorStore     # or .llamaindex; needs the langchain (or llamaindex) extra
store = ReceiptVectorStore(embeddings, source_labels={"wiki://handbook": {"trust": "verified", "license": "internal"}})

See the frameworks guide for LangChain, LlamaIndex, LangGraph, Haystack, Semantic Kernel and MCP, and the README for the HTTP API.

Where to go next