When should you use it?
- A supplier, client or scanner hands you many documents merged into a single PDF
- Documents vary in length, so splitting every fixed number of pages does not work
- Rule-based text matching keeps failing on scans or changing layouts
Not for: Files with sensitive data you are not allowed to send to OpenAI; One-off bundles small enough to split by hand in a few minutes
What do you need, and what do you get?
You need
- An n8n instance
- An OpenAI API key with billing set up (the Decisions API has no free tier)
- A way to turn PDF pages into images, such as StirlingPDF or your own tool
- A sample bundle where you already know the right split points
You get
- One file per document, cut where a new document starts
- A short list of pages the classifier could not decide, for you to check
- Optional per-document labels such as an invoice number, if you add an extraction step
How does it work, step by step?
- Pick a templateDownload the creator's template that is closest to your case (invoices, admissions packets or legal discovery) from his forum post and import it into n8n.
- Connect the servicesAdd your OpenAI key and your PDF-to-image service; the creator uses StirlingPDF, which also has a self-hosted version for more privacy.
- Describe a first pageEdit the question the workflow asks about each page so it lists what a first page looks like in your documents, using our prompt below as a starting point.
- Test on a known bundleRun it on a file where you already know the right answer and compare every split point.
- Add a review stepSend pages the classifier is unsure about to a person instead of guessing, then let the workflow save the split files.
The prompt
Our own prompt, inspired by Jim Le and written to work in n8n. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
You are looking at a single page taken from a bundle of {document_kind} that were scanned into one file. Question: is this page the first page of a new {document_kind}? Count it as a first page when you see {first_page_signals}. Count it as a later page when you see {continuation_signals}, for example a page number above 1 or a balance carried over. If the page is blank or you cannot tell, answer unsure rather than guessing. Reply with three items: first_page (yes, no or unsure), the clue you relied on, and the heading plus any reference number you can read on the page.
Inspired by Jim Le: n8n x OpenAI Decision API: Splitting batched PDFs for invoices, legal discovery and admissions. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- Every page you process is sent to OpenAI; check your contracts and privacy duties before running client or patient files through it.
- The creator notes that wording matters a lot for accuracy, so expect to rewrite the page question a few times for your documents.
- Blank separator pages, rotated scans and pages without numbers are where splits go wrong; test those specifically.
- The Decisions API is in public beta and its model, pricing and limits may change; recheck OpenAI's documentation before relying on it.
Our take
This solves a genuinely annoying back-office problem with very little machinery: look at each page once, decide whether it is a first page, cut. The creator's numbers are striking (about seven seconds and two cents for his 129-page invoice test), and he backs them with sample files you can rerun yourself. We could not call the Decisions API from our build box, so our dry run checked the decision logic rather than the service. We applied our page prompt to the text of a synthetic 12-page utility bundle with seven documents, a blank separator page, two documents without page numbers, a rotated scan and a final notice mixed in with invoices. All six real boundaries were found, the blank page was sent to review instead of being glued onto a document, and the split matched our answer key. The notice was correctly treated as a new document but nothing labeled it as a different type, so our prompt now asks for the heading as well. Speed and cost figures here come from the creator's post; we did not reproduce them.
Where the time goes back: Finding where each document ends in a long scan is slow page-by-page work; the workflow proposes every split point and leaves you only the uncertain pages.
FAQ
What is the Decisions API?
Can I use this for legal discovery?
Is the creator selling something?
Source and credit
Inspired by Jim Le. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- n8n x OpenAI Decision API: Splitting batched PDFs for invoices, legal discovery and admissions
- Creator
- Jim Le
- Published on
- n8n Community
- Original date
- Oct 12, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- n8n
- AI dry run
- Oct 22, 2026: passed. Dry-run tested by our AI test agent on sample input. Decision logic and split rule checked; speed and cost figures are the creator's, not reproduced.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.