invoice-extraction
Published
Public
in @structured-extraction

Turn a raw invoice or receipt into structured JSON — vendor, invoice/due dates, currency, line items, subtotal, tax, and total. Dates normalized to ISO 8601, amounts to plain decimals. Optional locale hint disambiguates date and number formats. A worked, strongly-typed specialization of key-information-extraction.

invoice-extraction

Turn the raw text of an invoice or receipt (pasted or OCR'd) into clean, strongly-typed JSON: vendor, invoice and due dates, currency, line items, subtotal, tax, and total. Dates are normalized to ISO 8601 and amounts to plain decimals.

This is the worked, fixed-schema specialization of key-information-extraction — use it when your input really is invoices and you want typed numbers and dates out of the box.

Entrypoints

EntrypointRendersInputs
systemPromptInstructions, field list, normalization rules + embedded schemaoptional localeHint
userPromptThe delimited invoice documenttext

Variables

  • text (string, required) — the raw invoice/receipt text.
  • localeHint (string, optional) — disambiguates date and number formats, e.g. "US" (MM/DD/YYYY, 1,234.56) vs "EU" (DD/MM/YYYY, 1.234,56). Omit if the document is unambiguous.

Output (shape)

{
  "reasoning": "Standard one-page invoice; total and tax printed, due date inferred from terms.",
  "vendor": { "name": "Acme LLC", "address": "1 Main St, Springfield", "tax_id": "GB123456789" },
  "invoice_number": "INV-2042",
  "invoice_date": "2026-05-01",
  "due_date": "2026-05-31",
  "currency": "USD",
  "line_items": [
    { "description": "Widget", "quantity": 3, "unit_price": 19.99, "amount": 59.97 }
  ],
  "subtotal": 59.97,
  "tax": 5.40,
  "total": 65.37
}
  • reasoning first (house convention).
  • Numbers are real numbers — amounts have no currency symbols or thousands separators; dates are ISO 8601 strings. parseOutput() gives you typed values directly.
  • Missing fields are null, never invented. The single computed exception: a line amount may be filled as quantity × unit_price when both are present and no line total was printed.

House conventions

  • Triple-mustache for text so symbols, ampersands, and angle brackets survive.
  • <document> delimiters around the input for clearer parsing and injection-resistance.
  • No hallucinated valuesnull for anything not on the page.
  • Strict schemaadditionalProperties: false on every object.

Notes

Verified by local render (with and without localeHint). Suggested default claude-sonnet-4-6 at temperature: 0. For high-volume or compliance-critical pipelines, validate totals (subtotal + tax ≈ total) in your own code as a cheap sanity gate.

@sufleur/