Adding Document Intelligence to AI Agents with ParseAI Extract
Most AI agents can reason and act. What they cannot do is read a scanned PDF. Here is how to give them that capability.
ParseAI Editorial Team
Document automation research and analysis
AI agents built on large language models can browse the web, run code, query databases, and call APIs. What they consistently struggle with is reading unstructured documents — PDFs, scanned images, and forms. The reason is straightforward: LLMs are not reliable document parsers. Feeding a raw PDF binary to an LLM is not a solution. Feeding raw extracted text from a poorly structured PDF is only marginally better.
Adding the ParseAI Extract API as a tool in your agent's toolkit gives the agent a reliable document reading capability. The agent can submit a document and a schema, receive structured JSON in response, and use those values to reason and act.
Why Agents Need a Dedicated Document Tool
The standard tool call paradigm works because it offloads specific tasks to systems that are purpose-built for them. You do not ask an LLM to query a database directly — you give it a database query tool. You do not ask it to send an email directly — you give it an email tool.
Document reading follows the same pattern. An extraction API is purpose-built for reading documents and returning structured data. The LLM's job is to decide what to extract and what to do with the results — not to do the extraction itself.
How It Works as a Tool Call
In an agent framework, the Extract API integrates as a function tool. The tool definition looks roughly like this:
- Tool name: extract_document_fields
- Input: document_url or document_bytes, plus a schema (list of field names and descriptions)
- Output: JSON object with field values and confidence scores
The agent decides when to call this tool and what schema to use based on the context of the task. For a loan processing agent, the schema for a bank statement is predefined. For a more general-purpose document agent, the agent itself may generate the schema based on what information it needs.
Example: Loan Processing Agent
A loan processing agent receives an application with attached documents. It needs to verify income, check existing obligations, and compute a preliminary FOIR before routing to a credit analyst.
The agent's workflow using ParseAI Extract:
- Receive the application with attached bank statements, salary slips, and KYC documents
- Call extract_document_fields on each salary slip with a schema for: employer_name, gross_salary, net_salary, pay_month
- Call extract_document_fields on each bank statement with a schema for: average_monthly_balance, total_salary_credits, total_emi_debits, inward_bounces
- Use the structured values to compute income stability and FOIR
- Route to credit analyst with a structured summary and any low-confidence fields flagged for review
The agent does not read the PDFs. It receives structured data from the extraction tool and reasons on that data. The extraction tool handles OCR, layout understanding, and field identification.
Example: Insurance Claims Agent
An insurance claims agent processes incoming claim packets containing discharge summaries, bills, prescription records, and pre-authorization forms.
The agent calls Extract with different schemas for each document type:
- Discharge summary schema: admission_date, discharge_date, diagnosis_codes, treating_physician, hospital_name
- Hospital bill schema: total_amount, itemised_charges, patient_name, admission_number
- Pre-auth form schema: approved_amount, approved_procedure, insurer_reference_number
The agent correlates values across documents — does the billed amount match the pre-authorised amount? Are the dates consistent? Are the patient details the same across all documents? Discrepancies are flagged automatically without a human reading multiple PDFs.
Confidence Scores in Agent Workflows
Confidence scores are especially useful in agentic workflows because the agent can act on them programmatically. The agent can be instructed:
- If all fields above 0.85: proceed automatically
- If any field between 0.70 and 0.85: include in human review summary, do not block workflow
- If any field below 0.70: halt that document's processing and escalate
This is more reliable than asking the agent to "be careful about uncertain values." Explicit numeric thresholds give the agent a clear rule to apply consistently.
Async Processing for Long Agent Runs
For agents processing large document batches — hundreds of files in a single run — synchronous API calls can block the agent. ParseAI supports webhook delivery: submit documents, receive results via webhook when processing is complete. The agent submits the batch, handles other tasks, and processes results as they arrive.
Zero data retention applies to all Extract API calls, including those made from agent frameworks. Documents are processed in memory only. This matters for agent workflows handling regulated or sensitive documents.
See ParseAI on your documents
Send us 10 documents from your workflow. We'll show you the extraction output in 24 hours.
Book a demo