LunaCost Autopilot

Cheaper JSON extraction with LLMs, without losing accuracy

A pattern for invoice, catalog and form extraction: try a small model first, check its output deterministically, and escalate only the tasks that fail the check.

The pattern

  1. Cheap first. A small model extracts the fields into your JSON schema.
  2. Deterministic self-check. Code, not a model, validates the output: schema validity, required fields present, types and formats (dates, currency codes, totals that add up).
  3. One escalation. If the check fails, the same task goes once to your current baseline model, and that answer is used.
  4. Measure per accepted task. Compare cost per accepted output, not per call, against the baseline alone, on the same tasks and your acceptance test.

What it did on open data

275 unseen synthetic invoices (Privoid, Apache-2.0), 7 fields. Baseline alone: 263/275 accepted, 1 critical error. Policy: 259/275 accepted, 0 critical errors, 59 escalations (21.5%), 67.8% lower cost per accepted task (95% interval 62.8% to 72.7%). The policy accepted 4 fewer documents; whether that trade-off is acceptable is your call, which is why the pilot uses your acceptance test.

Example acceptance test

{"required": ["invoice_number","issue_date","currency","total_net","total_tax","total_gross","seller_vat_id"],
 "checks": ["issue_date is ISO 8601", "currency is ISO 4217",
            "abs(total_net + total_tax - total_gross) <= 0.01"],
 "critical": ["total_gross", "currency"]}

A critical field wrong in an accepted output counts as a critical error. The report shows these separately.

Where it fits, and where it does not

Good fit: high-volume extraction or classification with a checkable expected result, no personal data, monthly AI spend above about $10,000. Poor fit: open-ended chat, long reasoning, tasks where correctness cannot be checked by code.

Estimate your saving   Start a free shadow pilot