Accrue
LLM enrichment for tables and documents, in Python.
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).
A 5,000-row run in Accrue Watch: every step, model, field and dollar, read live from the run log.
Using Claude Code or another coding agent? The /accrue-data-enrichment skill builds this for you from a sentence:
> /accrue-data-enrichment 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 and other agents
Accrue has a /accrue-data-enrichment skill for Claude Code. Describe the job and it designs the fields, tries them on a few rows, estimates the cost and writes the script for you to review and run. Install it in the project you're working in:
/plugin install accrue --marketplace matt-house-e/accrue
For other agents, or without the plugin: npx skills add matt-house-e/accrue --skill accrue-data-enrichment.
> /accrue-data-enrichment
> 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.
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=Truewrites 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, OpenAI and Gemini models):
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)
Changing the prompt
Accrue writes the prompt from your field specs, and you can read and change all of it.
step = LLMStep("extract",
fields={...},
system_prompt_header="Listings come from UK office-furniture suppliers.", # add context about the job
outside_knowledge=False, # extraction: tell the model to answer only from the row
)
print(step.row_independent_system()) # the exact prompt, without calling a model
system_prompt_headeradds your context to the generated prompt. Most jobs need only this.outside_knowledge=Falseis for reading values off a page. By default the model may fill a gap from what it knows, which suits research (a company name in, its industry out) but not a contract or a listing. The switch greatly reduces filling from memory but isn't a guarantee, so check extraction that matters.system_prompt="..."replaces the generated instructions with your own. Your field specs are still appended, and types and enums are still enforced.
The prompt accrue sends shows the full default prompt and has a template to start your own from.
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:
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_examplesanddefault. Accrue turns them into a structured-output schema and validates every answer. Field specs guide -
A prompt you can read and replace. Accrue writes the prompt from your field specs. You can print it without calling a model, add context with
system_prompt_header, setoutside_knowledge=Falseto tell the model to answer only from the row, or swap in your own withsystem_prompt=. The prompt accrue sends -
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=Trueuses 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, OpenAI and Gemini. Attachments guide -
Conditional steps.
run_ifandskip_ifdecide 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 cantail -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 |
| The accrue skill | Installing the skill and building pipelines with /accrue-data-enrichment |
| 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.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| accrue-1.9.1.tar.gz | 217.6 kB | With provenance | Details for accrue-1.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| accrue-1.9.1-py3-none-any.whl | Python 3 | none | any | Details for accrue-1.9.1-py3-none-any.whl |
Total release size: 401.9 kB
Release files / accrue-1.9.1.tar.gz
| Download URL | accrue-1.9.1.tar.gz |
|---|---|
| Size | 217.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61af9a21ba30591ba03dd6260c44fdeddc14a9fee585df14179d365984d89f03
|
|
BLAKE2b-256 checksum How to use checksums |
8e470f144caf953a6edf3bdee667597cd0587b1ebd0105289ecacf4bf4f4a507
|
| 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 29, 2026.
Transparency logRelease files / accrue-1.9.1-py3-none-any.whl
| Download URL | accrue-1.9.1-py3-none-any.whl |
|---|---|
| Size | 184.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c003258c3ebf43360aebdffa1d28d4349f8d4915acd712258c2ee21cccd70e6
|
|
BLAKE2b-256 checksum How to use checksums |
621fdc6c1e366e4005afa17bc695be6d71c521070e026f1bd2501e7888a62f03
|
| 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 29, 2026.
Transparency logSecurity for accrue 1.9.1
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.
Attestation for accrue-1.9.1.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 29, 2026.
Transparency logA 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.