Skip to main content
Last updated: April 2026 — The Paradigm API evolves fast. Always check the latest API reference and prefer more recent cookbook entries when available.

Overview

Verifying that information is consistent across a set of related documents — procurement forms, contracts, bank details, identity declarations — is tedious, error-prone, and expensive when done manually. This cookbook shows how to build an automated verification pipeline that uploads documents to Paradigm, extracts specific fields using Document Search, and cross-references them using Chat Completions with structured prompts. The pattern is applicable to any multi-document verification workflow: compliance audits, insurance claims processing, loan applications, supplier onboarding, and more.
This example is based on a real production use case verifying French public procurement forms (DC4). The pattern generalizes to any scenario where you need to check consistency across multiple documents.

Demo

See the pipeline in action — uploading documents, running automated checks, and generating a verification report:

How It Works

  1. The user uploads a set of related documents (e.g., a form, a contract, bank details, an identity declaration).
  2. Documents are ingested into Paradigm via the Upload Sessions API.
  3. For each verification check, specific fields are extracted from the relevant documents using Document Search.
  4. Extracted fields are compared using Chat Completions with a structured system prompt that handles fuzzy matching (typos, formatting differences, abbreviations).
  5. Each check returns a structured result: is_correct, the compared values, and details explaining the decision.
  6. All results are compiled into a verification report.
Document verification pipeline — architecture diagram showing document upload, field extraction, cross-referencing, and report generation

Prerequisites

  • A Paradigm API key (get one here)
  • Python 3.10+
  • Documents to verify (sample documents are included in the GitHub repo)

API Endpoints Used

Step-by-Step Implementation

Step 1: Set Up the Paradigm Client

Create a wrapper around the Paradigm API. This client handles authentication, document upload, field extraction, and cross-referencing.

Step 2: Upload Documents

Documents must be uploaded to Paradigm before they can be queried. The Upload Sessions API manages the ingestion pipeline — you create a session, upload files to it, then close the session to trigger embedding.
Documents must be fully embedded before they can be queried. Embedding time depends on document size and complexity — typically a few seconds to a few minutes.
Once documents are embedded, use Document Search to extract specific fields. The query parameter is a natural language question — Paradigm searches the document and returns the relevant content.
Example queries for extracting fields:

Step 4: Cross-Reference Fields with Chat Completions

This is the core of the verification pipeline. After extracting the same field from two different documents, use Chat Completions with a structured system prompt to compare them. The system prompt handles real-world messiness: typos, formatting differences, abbreviations, missing accents.
The system prompt above is critical to handling real-world data. Tune the fuzzy matching rules to your domain. For example, if verifying financial documents, you might want strict matching on amounts but fuzzy matching on company names.

Step 5: Define Verification Checks

Each check is a function that extracts a field from two documents and compares them. Here’s the pattern — repeat it for each field you need to verify.

Step 6: Orchestrate All Checks

Run all verification checks in parallel for speed, then compile results into a report.
Expected output:

Step 7: Generate a Verification Report

Compile all results into a structured report. The example below generates a simple summary — in production, you might generate a PDF or write to a database.

Complete Code

Full source code

Clone the repository to run the complete pipeline with sample documents.

API Reference

Full Paradigm API documentation.

Customization

Adapt this pipeline to your own verification needs:

Adding Your Own Checks

To add a new verification check, follow this three-step pattern:
  1. Extract the field from document A using search_document() with a clear natural language query
  2. Extract the same field from document B
  3. Compare using cross_reference() — the system prompt handles fuzzy matching

Best Practices

  1. Use VisionDocumentSearch for scanned documents — standard DocumentSearch works for native PDFs, but scanned documents and images need the vision tool for reliable extraction.
  2. Keep extraction queries specific — “What is the IBAN?” works better than “Extract all banking information.” One field per query yields more reliable results.
  3. Tune the system prompt for your domain — the fuzzy matching rules should reflect your business requirements. Financial data may need exact matching; names and addresses typically need fuzzy matching.
  4. Run checks in parallel — each check is independent, so use threading to process them concurrently. Add a small delay between batches if you hit rate limits.
  5. Log intermediate results — when a check fails, having the raw extracted values from both documents makes debugging much faster.