All patterns · 13 of 13 · In one process
Agentic patterns: Invoice to pay
One invoice travels from the mailbox to the bank through nine patterns of this series, and leaves an evidence file behind.
One invoice, start to finish. A small model reads it, code checks it, rules or an agent decide, a person approves what policy says a person must, and the bank is paid once.
Demo: One invoice, start to finish. Recorded on 26 November 2026 with Claude Haiku 5.5 and Claude Opus 5.5: the model’s answers are real, replayed here. The suppliers, the records and the bank are a small simulation.
What you just saw
What the invoice to pay demo shows
The principle
What is invoice to pay?
Invoice to pay is the accounts payable process from receiving a supplier invoice to paying it, shown here as a workflow in which code, two model steps and people each do the part they are suited to.
The patterns in this series are parts. A real process uses several at once, and the design work is in how they fit. This page runs one accounts payable process end to end: extraction with validation and retry, a decision table with an exception lane, an agent inside the workflow for the exceptions, an approval gate above a limit, a guard on bank details, and a payment that can only happen once.
Three invoices take three routes. A clean one needs a single small model call and no person. One with a surcharge goes to the exception agent and then waits for a manager, because it is above €10,000. One with new bank details never reaches a model that could be persuaded: a rule stops it and a phone call settles it. Each run ends with an evidence file that lists what happened, in order, with the request id of every model call.
Where it applies
- Accounts payable, claims handling, customer onboarding: document in, decision and action out
- Processes where most cases are plain, some need reading, and a few need a person
- Organisations that have to show an auditor how each case was handled
- A first agentic project, because every model step is small and fenced in
Where it does not
- Open-ended work with no fixed process, such as research or coding
- Processes where every case is different and needs judgement throughout
- Teams that want to hand a whole process to one agent and see what happens
Fill the boxes
One shape, three ways to build it
The pattern exists with or without AI. The design decision is which boxes deserve a model, and what that costs in money, speed and auditability. In the first run above, six steps were done: 5 by code, 1 by a model.
All code
Templates extract the fields and rules decide. Fast and exact for the suppliers whose invoices fit the template, and a manual queue for the rest.
- Cost
- Free
- Speed
- Instant, for invoices that fit the template
- What the auditor gets
- Rules and results
Hybrid shown above
A small model reads, code checks and decides, an agent takes the exceptions, and people approve what policy says they must.
- Cost
- $0.0001 of model calls in the run above
- Speed
- Seconds, plus any waiting for a person
- What the auditor gets
- One evidence file per invoice
All agents
One agent receives the invoice and the tools and is told to get it paid. It will often succeed. You will not be able to say in advance what it will do.
- Cost
- Many model calls per invoice
- Speed
- Seconds to minutes
- What the auditor gets
- A transcript to read
codemodelagentperson
What it costs
The price of each run, and of ten thousand
A clean invoice costs a hundredth of a cent in model calls. An exception costs two cents. Most of the money in a process like this goes to the people who approve and phone, which is where it should go.
Measured from the runs recorded with Claude Haiku 5.5 and Claude Opus 5.5 on 26 November 2026. Model calls only: people’s time and infrastructure come on top.
| Run | Model calls | Cost per invoice | Per 10,000 invoices |
|---|---|---|---|
| A clean invoice | 1 | $0.0001 | $1.50 |
| A surcharge, and over the limit | 3 | $0.022 | $218 |
| New bank details | 1 | $0.0002 | $1.59 |
In a regulated process
What the auditor gets
The evidence file is the audit trail. For each invoice it lists, in order, how the document arrived, which model extracted it and under which request id, which checks passed, which rule or which agent decided and why, who approved, and the bank’s reference with the key that makes the payment unique. Nothing has to be reconstructed afterwards.
Lineage
Where the shape comes from
A process that carries a case through steps, waits for people and remembers where it is, is what Enterprise Integration Patterns calls a Process Manager and what workflow engines have done since the 1990s. Each step here has its own page in this series, and each of those names its own ancestors. Put together they form what organisations have always called a procedure.
Also known as Process Manager (Enterprise Integration Patterns) · Workflows with agents inside (Anthropic) · Sequential orchestration (Azure Architecture Center) · Procure-to-pay (finance operations)
Advice
Questions I ask before using it
- Which steps are rules today, and which really need reading?
- What is the smallest model that can do each model step?
- Where does a person have to sign, and where is a person only a fallback?
- What would the evidence file for one case have to contain to satisfy your auditor?
Asked often
Invoice to pay: short answers
What is invoice to pay?
Invoice to pay is the accounts payable process from receiving a supplier invoice to paying it, shown here as a workflow in which code, two model steps and people each do the part they are suited to.
When should you use invoice to pay?
Typical uses: accounts payable, claims handling, customer onboarding: document in, decision and action out; processes where most cases are plain, some need reading, and a few need a person; organisations that have to show an auditor how each case was handled. It is a poor fit for open-ended work with no fixed process, such as research or coding.
Which patterns does this process combine?
Validate and retry for extraction, an exception lane with an agent inside a workflow, a human approval gate above €10,000 with separated duties, a guard on bank details, and retry with an idempotency key for the payment. The decision table could be written by an agent at design time.
How much of invoice processing needs AI?
In these runs, one small model call to read the document, and an agent only when no rule fits. Everything that checks, decides by rule, pays and records is ordinary code.
What is an evidence file?
A record, written as the process runs, of every step taken on one case: inputs, model calls with their identifiers, rules applied, approvals and results. It is what lets someone verify the handling of a case later.
What does invoice to pay cost to run?
In the demo, model calls cost between $0.0001 and $0.022 per invoice, which is $1.50 to $218 per 10,000 invoices. A clean invoice costs a hundredth of a cent in model calls. An exception costs two cents. Most of the money in a process like this goes to the people who approve and phone, which is where it should go. Measured from the runs recorded with Claude Haiku 5.5 and Claude Opus 5.5 on 26 November 2026.
The demo in detail
The run in words “A clean invoice”, step by step
One invoice travels from the mailbox to the bank. A small model reads it and code checks the fields. A decision table settles it or passes it to an agent. Payments above €10,000 wait for a person, a change of bank details waits for a call-back, and the payment carries a key so it can never go out twice. Three invoices take three routes.
- INV-01 from Noordzee Logistics, for €4,200.
- A small model reads the PDF and fills in the fields.
- Code checks the fields: the order number, the currency, the IBAN, and that the lines add up to the total. All pass.
- The decision table finds that order, receipt and bank account match. Decision: pay.
- The bank executes the payment once, under key pay-INV-01. Reference BNK-7107.
- The evidence file has 6 lines, with the request id of each model call. Model cost for this invoice: $0.0001.
- Done. One small model call, and everything else was code.
Building it This demo runs on plain Python and the Claude API: when I would pick it, and when not
This demo uses no agent framework: one Python function carries an invoice from the mailbox to the bank and calls a model at two points. Other frameworks can carry the same pattern; this is when I would pick this one.
Reach for it when
- The process is yours and you want to read every line that touches money
- A decision table, a loop and a few API calls cover the job
- You need the recording and the control points more than a framework’s features
Skip it when
- Runs must survive a crash or wait days for a person: take a durable workflow engine
- Several teams build agents and need one shared way of working
- You would end up rebuilding checkpoints, retries and tracing by hand
In the framework’s own terms. The process is ordinary code with two model steps: a small model extracts the fields and a larger one, with tools, handles what the decision table cannot. Every step appends one line to the evidence file, including the request id of each model call.
- Framework
- Plain Python and the Claude API (anthropic SDK 2.10)
- Licence
- MIT
- Model
- claude-haiku-5-5, claude-opus-5-5
- Watch time
- ~2 min
Contact
Questions, ideas or a conversation?
I’m always glad to hear from people working on AI, product strategy, transformation or software.