Skip to main content

Accrue
LLM enrichment for tables and documents, in Python.

PyPI Python License

Documentation


Accrue uses an LLM to fill in structured fields across a table of records or a folder of documents. You describe each field once, point it at a DataFrame, and get typed columns back: categories, scores, extracted values, short summaries.

It's built for jobs of a few hundred to tens of thousands of rows, where the cost, the reruns and checking the results all matter. For example:

  • tagging or classifying free text: support tickets, survey answers, reviews
  • comparing hundreds of products or supplier offers on the same criteria
  • pulling the same fields out of a pile of contracts, papers or reports
  • researching and scoring a list of companies
from accrue import Pipeline, LLMStep

pipeline = Pipeline([
    LLMStep("extract", fields={
        "category": {"prompt": "What the product is", "enum": ["chair", "desk", "lamp", "storage"]},
        "unit_price_gbp": {"prompt": "Price per single item ex VAT, in pounds", "type": "Number"},
        "warranty_years": {"prompt": "Warranty in years", "type": "Number"},
        "fire_rated": {"prompt": "Is it fire rated?", "enum": ["yes", "no", "unknown"]},
    }),
])

# Runs the first rows, prints the prompt, schema and token estimate, then asks before the rest
result = pipeline.run(listings_df, confirm=True)  # DataFrame in, DataFrame out
print(result.data.head())

On 5,000 supplier listings like these, plan() measured 5 rows and estimated about 3.1M input and 310K output tokens. On the default model, gpt-6-luna, that's about 50 cents, or about 25 cents with batch=True. It's an estimate, not a quote (prices).

Accrue Watch, Overview tab: a live 5,000-row enrichment run with its pipeline steps, models, produced fields, and cost
A 5,000-row run in Accrue Watch: every step, model, field and dollar, read live from the run log.

Using Claude Code? The /accrue skill builds this for you from a sentence:

> /accrue I have 5,000 supplier listings in listings.csv. Pull out category, unit price,
  warranty and fire rating. Try it on 5 rows and show me the cost, then run the rest.

Install

Requires Python 3.10+.

pip install accrue

Set your API key:

export OPENAI_API_KEY=sk-...

OpenAI is the default provider, with structured outputs switched on. Anthropic and Google are optional extras:

pip install "accrue[anthropic]"  # Claude
pip install "accrue[google]"     # Gemini

You're not tied to those three. Any API that speaks the OpenAI format works through base_url, including local models, so your data can stay on your own machine:

LLMStep("extract", fields={...}, model="llama3", base_url="http://localhost:11434/v1")  # Ollama

That covers OpenRouter (one key for hundreds of models), Ollama, vLLM, Groq, Together, Fireworks and others. The provider batch APIs aren't available through these. For anything else, a custom provider is one async method. Providers guide

Using it with Claude Code

Accrue ships a /accrue skill for Claude Code. Describe the job and it designs the fields, picks a model, estimates the cost and writes the script for you to review and run.

> /accrue
> I have 500 companies in accounts.csv, I need to qualify them for ICP fit.
  Try it on 5 rows first and show me the results.

See Using the Claude Code skill.

Why Accrue

There are two usual ways to do this job. You can write a loop over an LLM SDK, or you can use a platform like Clay. A loop leaves you to build retries, rate limits, caching, progress and crash recovery, and to do it again for the next job. A platform does that for you, but you pay a monthly plan plus credits for each run, your pipeline lives in their UI rather than your repo, and your data goes through them.

Accrue sits between the two: a library that does the plumbing, runs on your own API keys, and keeps the pipeline in your code.

Loop over an SDK Accrue Clay
Multi-step Wire it up yourself Steps with dependencies, run in parallel Columns in a table UI
Caching Build it yourself Built in, invalidated when a prompt changes Managed by the platform
Crash recovery Start over Resumes from the last finished row Managed by the platform
Changing a prompt Re-run everything Re-runs only the affected step and rows Re-run the column
Cost API costs API costs Monthly plan, credits and per-run actions
Version control Yes Yes No

Why not a loop or an agent script?

A coding agent will write you a loop over the OpenAI SDK in a minute, and for a one-off job of 50 rows that's fine. The trouble starts when the job comes back: new rows next month, a tweaked prompt, a cheaper model, someone asking why row 212 says what it says. Each time the agent writes a slightly different script, so the results don't line up and nothing carries over.

With accrue the job is a definition, not a script: your fields, prompts and steps in one short Python file that lives in git. Run it again and you get the same columns with the same types, and the framework around it does the rest.

  • You know the cost before you run. pipeline.plan(df, sample_size=3) runs a few rows for real, shows you the prompt and schema it will send, and estimates the tokens for the full run. run(..., confirm=True) does the same and asks before going on.
  • The output has a fixed shape. Field specs (prompt, type, enum, examples) become a strict schema, so every run fills the same typed columns instead of whatever the model felt like returning.
  • Re-runs only redo what changed. Results are cached against the row and the prompt, so new rows or an edited prompt cost only what's new. A crashed run picks up where it stopped, and retry_failed() re-runs just the rows that errored.
  • Batch pricing is one flag. LLMStep(batch=True) sends rows through the OpenAI and Anthropic batch APIs at about half price.
  • Runs can be compared. accrue.compare(before, after) shows which rows and fields changed after a prompt or model change, and what it did to the cost, without needing labelled data.
  • Repeated runs can be combined. For work someone will check, run it three times and accrue.merge_runs() gives one answer per cell plus the cells where the runs disagreed. That list is your review queue.
  • Every run is recorded. run_log=True writes each row's outputs, errors and token use to a log you can open in Accrue Watch, so you can answer "why does row 212 say that?" weeks later.

More examples

Read PDFs directly. Each row's documents go to the model as files, so there's no text extraction step (Anthropic models only for now):

pipeline = Pipeline([
    LLMStep("read_contract",
        fields={
            "counterparty": "Name of the counterparty",
            "term_months": {"prompt": "Contract term in months", "type": "Number"},
            "governing_law": "Governing law of the contract",
        },
        model="claude-sonnet-5-5",
        attachments="documents",
    ),
])

result = pipeline.run([
    {"deal": "Acme", "documents": "contracts/acme.pdf"},
    {"deal": "Beta", "documents": ["contracts/beta.pdf", "contracts/beta-amendment.pdf"]},
])

Chain steps with depends_on, and use web_search() to ground answers in live data:

from accrue import Pipeline, FunctionStep, LLMStep, web_search

pipeline = Pipeline([
    FunctionStep("research",
        fn=web_search("Research {company}: market position, competitors, recent news"),
        fields=["__web_context", "sources"],
    ),
    LLMStep("analyze",
        fields={
            "market_size": "Estimate TAM in billions USD",
            "competitors": {"prompt": "List top 3 competitors", "type": "List[String]"},
            "investment_thesis": "One-paragraph investment thesis",
        },
        depends_on=["research"],
    ),
])

result = pipeline.run(companies_df)

Watch It Run

Accrue Watch (accrue-ui) is a local dashboard for a pipeline run. It shows rows against steps as a live grid, each cell's values and errors, failures grouped by cause, and cost by step. It reads the run log accrue writes, so there's nothing else to set up. The Overview tab is at the top of this page; this is the run grid:

Accrue Watch, run grid in data view: one produced field per step, with retrying and failed cells highlighted in place
Run grid, data view: one field per step, filling in as rows complete. Retries and failures show in place.

Turn on the run log, then open the dashboard:

result = pipeline.run(companies_df, run_log=True)  # writes .accrue/runs/<run_id>.jsonl
pip install "accrue[ui]"   # the dashboard, alongside the engine
accrue watch               # opens the latest run in your browser

Add --pipeline module:attr to retry failed rows from the dashboard with one click. Run log guide

Features

  • Multi-step pipelines. Chain LLM steps and Python function steps. Accrue works out the order from their dependencies and runs independent steps in parallel. Quickstart

  • Any of the main providers. OpenAI, Anthropic (with automatic prompt caching) and Google are built in. Any OpenAI-compatible API works through base_url, and a custom provider is one async method. Providers guide

  • Field specs. Describe each output field with prompt, type, format, enum, examples, bad_examples and default. Accrue turns them into a structured-output schema and validates every answer. Field specs guide

  • Caching and checkpoints. A local SQLite cache keyed on each row and prompt, cleared automatically when the prompt changes. Progress is saved after each step so a crashed run can resume. Caching guide

  • Batch API. LLMStep(batch=True) uses the OpenAI and Anthropic batch endpoints for about half the price. It works with the cache, splits large jobs and falls back to normal calls for rows that fail. Batch guide

  • Web search. grounding=True uses the provider's own web search (OpenAI, Anthropic, Google) and returns cited sources. web_search() runs the search as its own step, so the analysis can use batch pricing and cached research. Web search guide

  • Attachments. LLMStep(attachments="documents") sends each row's PDFs to the model as documents, so you don't extract the text first. Cached by file content. Anthropic only for now. Attachments guide

  • Conditional steps. run_if and skip_if decide per row whether a step runs. Skipped rows get defaults and cost nothing. Conditional steps guide

  • Hooks. Typed events at each stage of a run, for logging and monitoring. A failing hook never stops the pipeline. Hooks guide

  • Run logs. run(..., run_log=True) writes the run as a JSONL file you can tail -f: each step and row with its status, errors and token use. Run log guide

  • Comparing runs. accrue.compare(result_a, result_b) shows what changed between two runs, for example before and after a prompt tweak: changed rows, how much each field moved, and the cost difference. Compare guide

  • Merging repeated runs. accrue.merge_runs([run_a, run_b, run_c]) combines several runs over the same rows into one answer per cell by majority vote. You get the agreement for each cell, the cells that need review, and the total cost. You can plug in your own rule per field, such as "prefer the run that quoted its source". Merge guide

  • provider_kwargs. Pass provider-specific options, such as extended thinking, straight through without waiting for accrue to support them.

How big a job?

Accrue is built for 100 to 50,000 rows: too many to do by hand or one call at a time, too few to need big-data infrastructure. Cost depends mostly on the model and how much text each row carries, so run pipeline.plan() on your own data for a real estimate, and price it from the model and price table. batch=True halves the API cost, and cached steps re-run in seconds.

Documentation

Section Description
Getting Started Installation, first pipeline, core concepts
Claude Code Skill Building pipelines with /accrue
Guides Field specs, providers, caching, batch API, web search, attachments, hooks, run logs, errors, configuration
Cookbook End-to-end examples: company enrichment, lead scoring, content analysis, batch processing
API Reference Every public export

Contributing

git clone https://github.com/matt-house-e/accrue.git
cd accrue
pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for accrue 1.7.0

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

Source distribution (sdist)

Source distribution for accrue 1.7.0
File Size Uploaded Provenance Actions
accrue-1.7.0.tar.gz 171.7 kB With provenance Details for accrue-1.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 342.4 kB

Release files / accrue-1.7.0.tar.gz

Download URL accrue-1.7.0.tar.gz
Size 171.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a8dd54075f419361d503950e376c4953bf3cc56dd2f546eee44a5014ce3ad2e6
BLAKE2b-256 checksum
How to use checksums
c17248cc7e26b5952d887580fbb9779a9fa4c5b68d7275e95bd4310ca6c10d28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Release files / accrue-1.7.0-py3-none-any.whl

Download URL accrue-1.7.0-py3-none-any.whl
Size 170.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
051c1ada7a7eea8400683a78413cb6d894e4f68ec7843f476fd3c709d32b259d
BLAKE2b-256 checksum
How to use checksums
cab254c57e4dc88ea491075fa3c8104daa386c18c5eede157c3e6138765548c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Security for accrue 1.7.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for accrue-1.7.0.tar.gz

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 Nov 28, 2026.

Transparency log

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.

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