# Invoice and document extraction

Extract invoice fields and line items, then validate quantities, totals and source evidence.

## Define the fields before choosing a model

Prepare representative invoices, including scans and unusual layouts, and a reference set labeled by a person. Separate invoice-header fields from line items. Preserve the original document and page location so every extracted value can be checked.

A useful output includes supplier, invoice identifier, date, currency, line descriptions, quantities, unit prices and totals. Represent unreadable or absent values explicitly rather than asking the model to complete them from context.

## Build the extraction flow

1. Convert the document into inputs supported by the chosen model. Direct PDF input is not universal; some workflows need parsing, OCR or rendered page images.
2. Request structured fields with source text or page references where your input pipeline supports them.
3. Validate the output shape in code. Distinguish missing fields from empty strings and numeric zero.
4. Recalculate line amounts, taxes and totals using decimal arithmetic outside the model.
5. Send mismatches and unreadable fields to a review screen that displays the original document beside the result.

## Use a deterministic check

An illustrative line with quantity `3` and unit price `19.50` has a pre-tax amount of `58.50`. If an extracted line reports `585.00`, the arithmetic check should flag it. This is a validation example, not a measured model result. Discounts, tax rules and rounding need their own explicit business logic.

## Evaluate changes

Keep the same labeled documents when changing a prompt or model. Measure correctness by field and line item, not only by whether the response parses as JSON. Include poor scans, multiple currencies, repeated descriptions and tables split across pages.

## Connect the implementation

Use [text model selection](https://seedrouter.ai/text-generation) and each model's documentation to check image and structured-output support. Your application owns document preparation, validation, review and accounting-system imports. SeedRouter does not replace bookkeeping software. Combine actual attempts with [current model rates](https://seedrouter.ai/pricing) when estimating the cost per reviewed document.

## Related resources

- https://seedrouter.ai/models/gpt-6-sol
- https://seedrouter.ai/models/claude-opus-5-5
- https://seedrouter.ai/integrations/n8n
- https://seedrouter.ai/industries/logistics
- https://seedrouter.ai/blog/claude-opus-5-5-prompting-guide
