Prerequisites
- Node.js 18+
- API keys for multiple providers (or OpenRouter for unified access)
- A document to process
When to Use Consensus
Consensus voting is valuable when:- Processing high-value documents (financial, legal, medical)
- Extraction errors have significant business impact
- You need confidence scores for extracted values
- Auditing requirements demand verification
Basic Consensus Configuration
Enable consensus on the extract node:Voting Strategies
Majority (Default)
Each field is voted on independently. The value with the most votes wins:- Run 1:
{ total: 1250.00 } - Run 2:
{ total: 1250.00 } - Run 3:
{ total: 1250.50 }
{ total: 1250.00 } (2/3 agreement)
Unanimous
All runs must agree for a value to be accepted:Weighted
Assign different weights to different providers or runs:Multi-Provider Consensus
Run extraction across different AI providers for diverse perspectives:Agreement Thresholds
Set minimum agreement levels:| Threshold | 3 runs | 5 runs | Description |
|---|---|---|---|
| 0.5 | 2/3 | 3/5 | Simple majority |
| 0.66 | 2/3 | 4/5 | Two-thirds majority |
| 0.8 | 3/3 | 4/5 | Strong consensus |
| 1.0 | 3/3 | 5/5 | Unanimous |
- Set to null
- Flagged for human review
- Returned with a confidence score
Accessing Consensus Results
The output includes agreement information:Observability Hooks
Monitor consensus execution:Complete Example: Financial Document Validation
Extract and validate financial data with high confidence:Cost Optimization Strategies
Consensus increases costs. Here are strategies to manage this:Tiered Consensus
Use single extraction for low-value documents, consensus for high-value:Selective Field Consensus
Run consensus only on critical fields:Conditional Re-extraction
Only run consensus when initial extraction has low confidence:Handling Disagreement
When providers disagree, you have options:Return Null for Uncertain Fields
Flag for Human Review
Return All Candidate Values
Using Doclo Cloud with Consensus
Configure consensus for cloud-based flows:Next Steps
Consensus Voting
Consensus configuration reference
Providers
Configure different providers
Extract Invoice
Basic extraction guide
Error Recovery
Handle provider failures