Invoice extraction with verification
An invoice pipeline needs two capabilities. Extract fills your schema. Verify checks one value against the text before you write it to a ledger.
This recipe uses one plain-text invoice. Convert your PDF to text first: the API reads text, not files. No API key is required during the launch period.
Extract the invoice header
Send the text and a JSON Schema. Describe every field: the description drives the match.
The real response:
Read it honestly. The invoice number, the date, the integer and the money field are right. customer is wrong: it repeats the vendor name instead of the billed company. Treat the whole record as a draft.
Verify the fields that matter
verify takes one field and one value. It reports what the text says for that field. Run it on the fields that carry money or identity.
Three real calls against the same invoice. Row three sends a wrong total on purpose.
Three rules come out of this table.
matchesistruewhenprobabilityis 0.5 or higher. A wrong total drops the probability to0.foundholds the spans the text really carries for that field. It is your debugging field.- The comparison lowercases both sides and removes every non-alphanumeric character.
$2,676.00matches2676. Containment counts only when the canonical value has 3 or more characters.
More than one span in found means the field is ambiguous, not confirmed. Send those records to review.
Build the review queue
Combine the extracted value and the verify result into one decision per field. Write only the fields that pass.
The invoice number lands at 0.65 and goes to review. The total lands at 0.997 and writes straight through. Raise ACT for fields that move money. Pick the numbers from your own data with tuning thresholds, not from this page.
Cost and limits
- One invoice costs one
extractcall plus oneverifycall per checked field. - Measured latency:
extractnear 0.72 s,verifynear 0.48 s. textaccepts up to 20,000 characters. Long text is chunked at 2,000 characters. Pre-split longer invoices yourself.- Send up to 32 invoices in one
textsarray. Results come back in input order. Each text costs one inference call. - Send
statementsorquestionsin a batch when you also screen the document with yes-no or answer. Extra statements and questions add no inference call; each adds only its own length to the billed input.
Next
- Extract, then verify — the general pattern behind this recipe.
- Extract — the full JSON Schema support matrix.
- Confidence routing — act, confirm, review and escalate bands.