Prerequisites
- Node.js 18+
- A Doclo API key or VLM provider API key
- An invoice document (PDF or image)
What You’ll Build
A flow that extracts:- Invoice number and date
- Vendor information (name, address, tax ID)
- Line items with descriptions, quantities, and amounts
- Totals (subtotal, tax, total)
Step 1: Define the Schema
The schema tells the AI what data to extract and in what structure. Use JSON Schema format with descriptions to guide extraction accuracy.Step 2: Set Up the Provider
Choose a VLM provider for extraction. For invoices with tables and complex layouts, a VLM provider works best since it can see the document visually.Step 3: Build the Flow
Basic Extraction Flow
The simplest approach is direct VLM extraction:With OCR Pre-Processing
For text-heavy invoices or when you need lower costs, parse first then extract:With Hybrid Input Mode
For maximum accuracy on invoices with visual elements (stamps, signatures, checkboxes), use both parsed text and visual context:Step 4: Run the Flow
Prepare the Document
Convert your document to base64:Execute the Flow
Step 5: Add Type Safety
Use TypeScript interfaces for type-safe extraction:Step 6: Enable Citation Tracking
Track which parts of the document each field came from:Step 7: Add Custom Instructions
Guide the extraction with additional instructions:Complete Example
Using Doclo Cloud
To process invoices via Doclo Cloud instead of running locally:Next Steps
Multi-Provider Extraction
Improve accuracy with consensus voting
Process Large Documents
Handle multi-page invoices
Schemas
Learn schema definition patterns
Citations
Track extraction sources