Why use /compare?

Our goal is to make it as easy as possible to compare Cardinal results to your current provider’s results. Through this endpoint, you’ll get a link to a side-by-side comparison UI. You’ll see Cardinal’s extraction next to your baseline (e.g., your current OCR/LLM system) for every file. Compare flow diagram

Endpoint

  • Endpoint: POST /compare
  • Auth: x-api-key: <YOUR_KEY>
  • Input: a file or fileUrl + optional original_results (string)
  • Output: same payload as /markdown plus dashboard_url pointing to the evals UI
  • UI Link: https://dashboard.trycardinal.ai/evals?filename=<comparison_id>

Example Request

import requests, json

files = {}  # or: {'file': open('invoice.pdf','rb')}
data = {
  'fileUrl': 'https://example.com/docs/invoice.pdf',
  'originalResults': '### Initial Markdown'
}
headers = {'x-api-key': 'YOUR_KEY'}

r = requests.post('https://api.trycardinal.ai/compare', headers=headers, files=files, data=data)
print(r.json()['dashboard_url'])

Example Response

You’ll get the full /markdown payload plus a dashboard_url:
{
  "success": true,
  "pages": [
    { "content": "ACME CORPORATION\nInvoice #INV-2024-001\n...", "height": 792, "width": 612 }
  ],
  "dashboard_url": "https://dashboard.trycardinal.ai/evals?filename=7db1f2f3-1a2b-4c5d-9e0f-112233445566"
}
Open dashboard_url to review Cardinal vs. your baseline side-by-side for this file (and navigate across the entire eval set).