Everything ReadAnyDoc does in the current version (0.4.4): every way in, every input and option, every stage and
branch a document goes through, and exactly what comes out. Each section names the file that holds the detail.
All of them run the same pipeline and the same tasks. The model calls use your own key (ANTHROPIC_API_KEY,
OPENAI_API_KEY for OpenAI models, or an OpenAI-compatible server).
PDF, PNG, JPG, GIF, BMP, WEBP, TIFF (one page per frame), HEIC (needs a decoder on the machine)
Pages are rendered and read by the vision model
Read natively
DOCX, XLSX, XLSM, CSV, PPTX, TXT, EML, MSG
Read straight into blocks: no rendering, no model call
Converted
DOC, XLS, PPT, RTF, ODT, ODS, ODP
Converted by LibreOffice (or macOS textutil for word-processing files), then read natively; error 415 naming the missing program when there is no converter
How the file arrives:
Python: a path, or bytes with filename=.
HTTP input: an upload (reducto://<id> or {"file_id": ...}), an http(s) URL (downloaded), jobid://<id> (reuse a finished parse), a list of these (several documents as one, pages numbered on), or a local path when READANYDOC_ALLOW_LOCAL_PATHS is on. See readanydoc/api/inputs.py.
A password-protected PDF:settings.document_password decrypts it to a working copy; the password is never stored.
Every Reducto parse option the HTTP API accepts can also be passed in Python with options=
(readanydoc/pipeline/request.py, readanydoc/pipeline/shaping/options.py).
flowchart TD
A[File] --> B{File type}
B -->|Office, CSV, TXT, email| N[Read natively into blocks<br/>no model]
B -->|DOC, XLS, PPT, RTF, ODT...| CV{Converter on<br/>the machine?}
CV -->|no| E415[Error 415:<br/>names the program to install]
CV -->|yes| N
B -->|PDF, image| P[Split into pages<br/>decrypt, page range]
P --> T[Triage, per page:<br/>text layer trustworthy / OCR layer / stale / garbage / none<br/>digital or scanned, rotation, handwriting likely]
T --> R1{Turned page and<br/>the evidence is clear?}
R1 -->|yes| ROT[Straighten it]
R1 -->|no| L
ROT --> L
L{Mode} -->|engine| LAY[Layout model on CPU<br/>Docling heron: tables, forms,<br/>figures, headers, footers]
L -->|model-only| RD
LAY --> RD
RD{Handwriting likely,<br/>and local OCR does<br/>not read it as print?}
RD -->|yes, engine| HW[Read with the<br/>handwriting model]
RD -->|no| PR[Read the page with<br/>the page model]
PR --> SC{Scanned page with tables<br/>that may be misread?}
SC -->|yes, engine| Z[Zoomed strip re-reads:<br/>a character changes only when<br/>two zoomed reads agree]
SC -->|no| V
HW --> V
Z --> V
V[Verify: empty, refused, cut off or looping reads retried;<br/>table grids repaired only into a consistent grid;<br/>printed totals checked] --> G
G[Ground: every word and cell matched to its position<br/>PDF text layer, else OCR; block types, form fields paired;<br/>each table read again on its own, kept only if cells agree] --> AS
N --> AS
AS[Assemble: running headers and footers across pages,<br/>one heading tree, tables and paragraphs<br/>continuing across pages linked] --> SH
SH[Shape: chunks, table format, filters,<br/>page markers, Reducto's JSON] --> OUT[Parse result]
Native files skip every model stage; converted files go through LibreOffice or textutil; a password decrypts a copy; page_range selects pages
Triage
pipeline/triage.py
Scores the PDF's own text layer against OCR words
text_layer_class: trustworthy (characters may be copied from it), ocr_layer, stale_ocr, garbage, none; plus handwriting_likely, rotation_suspect, ocr_confidence
Layout
pipeline/layout.py
Engine only. An open layout model on CPU finds typed, boxed regions
The regions are evidence only: they never replace the model's text
Read
pipeline/read.py
The vision model reads each page at the largest image size it keeps; up to 16 pages at once
Handwritten pages go to the handwriting model; scanned pages may get zoomed re-reads; form values come from fillable-PDF fields and label/value lines
Verify
pipeline/verify.py
Retries bad reads; checks table grids and printed totals
Problems become warnings and confidence flags; digits are never changed
Ground
pipeline/ground.py
Places every word and table cell on the page; sets block types (Header, Footer, Title, ...)
Word sources in order of trust: PDF text layer, OCR words, Tesseract when coverage is poor; a block with no word evidence gets an estimated box marked low, and no word box is ever made up
Assemble
pipeline/assemble.py
Whole-document structure
Merges tables only when merge_tables is asked for and the link is high-confidence
Shape
pipeline/shape.py
The output you asked for
Chunk mode, table format, filter_blocks, page markers, embedding summaries
Both are in readanydoc/profiles.py. The rule for every stage: the model's text is never changed without
independent evidence (a second zoomed read that agrees, the PDF's own text, a checked total).
Python:ParseResult with blocks (each type, content, bbox and confidence), markdown, tables, pages, usage (calls, tokens, cost_usd, seconds, per model), warnings and raw (Reducto's response).
HTTP: Reducto's parse response: result.chunks[].blocks[] with type, content, bbox and confidence, plus usage.
flowchart TD
A[Document + schema + options] --> S0{Schema given?}
S0 -->|no| SL[One call: the model picks<br/>clear field names] --> OUT
S0 -->|yes| CHK[Check the schema is valid JSON Schema<br/>400 if not]
CHK --> ST{parse?}
ST -->|yes, default| PARSE[Parse pipeline<br/>section 3]
ST -->|no, one stage| ONE[Model reads the file itself:<br/>PDF pages, or page images;<br/>citation words from the PDF's text layer,<br/>local OCR for scans and images,<br/>native text for Office files]
PARSE --> REL
ONE --> REL
REL{relevance_filter or<br/>request_pages?} -->|yes| RP[A call picks the pages<br/>that matter]
REL -->|no| PARTS
RP --> PARTS
PARTS[Split pages into parts:<br/>about 30,000 tokens each, or smaller<br/>for array_extract / deep_extract] --> MODE
MODE{Per part: how to ask} -->|deep_extract| TR[Answer with a source<br/>label for every value]
MODE -->|model with structured outputs| COMP{Does the API compile<br/>the whole reply schema?}
MODE -->|model without| PLAIN[Groups of fields,<br/>free JSON]
COMP -->|yes| SINGLE[One enforced call<br/>for the whole schema]
COMP -->|no| CODED[Coded format, same in every call:<br/>values as code / item / value,<br/>groups of 40 fields, document cached]
SINGLE --> CONV
CODED --> CONV
PLAIN --> CONV
TR --> CONV
CONV[Convert to your types<br/>'4,200' to 4200, 'yes' to true] --> REP{Breaks your schema?<br/>patterns, ranges, enums}
REP -->|yes, up to 2 times| FIX[Ask again for those<br/>fields only; kept only<br/>if it has fewer problems] --> CONV
REP -->|no| CARRY
CARRY{A later part misses a value<br/>the previous part's last row had?} -->|yes| REDO[Ask that part again,<br/>told where the last one ended]
CARRY -->|no| MERGE
REDO --> MERGE
MERGE[Merge parts; drop less complete<br/>copies of the same list item;<br/>record where parts disagree] --> DEEP{deep_extract?}
DEEP -->|yes| DC[Arithmetic and overlap checks;<br/>re-ask failing fields, up to 2 rounds;<br/>confidence high or low]
DEEP -->|no| NULL
DC --> NULL
NULL[Whatever still breaks the schema<br/>becomes null; warnings for empty<br/>required fields and unreadable replies] --> CIT
CIT{citations or review?} -->|yes| FIND[Find each value on the page<br/>in code, no model]
CIT -->|no| OUT
FIND --> ALT{alternatives?}
ALT -->|yes| AV[Other values, in the field's<br/>format, with their boxes]
ALT -->|no| RV
AV --> RV
RV{review?} -->|yes| RF[Review flags, code only,<br/>including values the output left out]
RV -->|no| OUT
RF --> OUT[Result]
The reply schema. Your schema is rewritten in code so the API can enforce it (tasks/reply_schema.py):
every field becomes required;
"or null" is dropped, and an empty string means "not in the document";
numbers and yes/no answers are written as text, then turned back into your types.
Size limits. The API accepts at most 24 optional fields and 16 fields with more than one type per request.
Single: the whole reply schema compiles, so one enforced call is made.
Coded: it doesn't compile. Every call then uses one fixed format, {"values": [{"code", "item", "value"}]}, with codes from your own fields. The format is the same in every call so the document is cached once, and groups of 40 fields run side by side. A reply cut off at the length limit is split into halves on list boundaries.
Plain: a model without structured outputs gets groups of fields as free JSON.
Output allowance. On Anthropic models the reply may use the model's whole output allowance, from its public limits, so a long answer is not cut off. You are billed only for the tokens written.
Part size. The default is 30,000 tokens per part, capped by the model's context window and price jump. Each limit is looked up by model ID (model_limits.py); there is no guessing.
Marks for citations. With citations on, each object also carries:
_block: the label of the block its values came from;
_from: for values not printed word for word (a period from a column heading, a scale from "in millions"), the printed words they come from.
These marks are removed before you see the output.
- Instructions added to every call.
- Copy names, titles and labels exactly, every word.
- Text between ~~ is crossed out.
- With derived_values=False: do not work out or assume values.
Parts. The document is split into parts, with one page shared between neighbouring parts, and the parts run side by side.
Carried values. A part whose first rows miss a value printed only on an earlier page (a heading) is asked again, told where the previous part ended.
Merging. Lists from all parts are merged. A less complete copy of an item that another part also wrote is dropped. Values that differ between parts are recorded as segments_disagree.
Short lists. With enforced output, a list that looks short against the table rows of its pages is reported in warnings, never re-asked.
Citations are found by code after the answer; the model doesn't write them.
How a value is found. Each value is searched for inside its block (_block), then on the page.
Numbers are matched as numbers and dates as dates.
A worked-out value is boxed on the printed words its _from mark names.
What is never boxed. A category (enum) value is never boxed somewhere it isn't printed, and a short repeated value is never boxed at a guess.
What each citation gives. The printed text, its box (page and position as fractions of the page) and a confidence: high, or low when the value is printed in several places.
Confidence means evidence, not probability. The tiers come from how the value was found, not from a calibrated probability (concepts/citations.md).
flowchart LR
D[Parsed document] --> SP[Split: one call per window of pages<br/>assigns pages to your sections<br/>and partitions]
SP --> SPC{deep_split?}
SPC -->|yes| SPV[Verify pass: every page gets an<br/>evidence quote checked against the page]
SPC -->|no| SPO[splits: name, pages]
SPV --> SPO
D --> CL[Classify: one call answers yes/no<br/>for every criterion of every category]
CL --> CLC{model: accurate?}
CLC -->|yes| CLQ[Each yes needs a quote found<br/>in the pages, else low]
CLC -->|no| CLO[category; confidence = share<br/>of its criteria met]
CLQ --> CLO
F[Source file] --> ED{File kind}
ED -->|PDF with form fields| EW[Map instructions to fields,<br/>write values, flatten if asked]
ED -->|flat or scanned PDF| EF[Detect fields on page images<br/>if no form_schema, create real fields,<br/>write values in red]
ED -->|DOCX| EX[Content controls and empty<br/>cells next to a label]
EW --> EO[Filled file + form_schema<br/>with value and filled]
EF --> EO
EX --> EO
Task
You give
You get
File
Split
Section names and descriptions, optional partition_key, deep_split
splits: each section's pages (sections with no pages left out); with deep_split, evidence and confidence per page
tasks/split.py
Classify
Categories, each with criteria; optional model: "accurate"
category, confidence per category (share of criteria met)
tasks/classify.py
Edit
A file, edit_instructions, optional form_schema and edit_options (flatten, color)
The filled file, and the form_schema with each field's value and filled
Calls. Synchronous calls return the response. Calls ending in _async return a job_id.
Poll /job/{id}, list jobs with /jobs, and cancel with /cancel/{id}.
/configure_webhook sends a webhook when a job finishes (api/webhooks.py).
Chaining tasks./parse, then /extract or /split with input: "jobid://<job_id>", reuses the parse without paying for it again. /pipeline is deprecated, as on Reducto.
Settings. Profiles, keys, storage, limits and security are set by READANYDOC_* variables (Configuration).
Invalid schema, invalid page range, part_tokens under 1000, or a model whose limits are unknown and no part_tokens given
415
A file type with no converter on the machine; the message names the program to install
501
A Reducto feature not implemented (/pipeline)
502
Every model call failed (cut off or unreadable), so the answer would have been empty
warnings
Empty required fields, unreadable replies (with their pages), lists that look short, printed values the output left out (on by default; left_out_warnings: false turns it off), copied examples, parse problems by stage