Errors
If the model returns broken JSON, the service sends it back for a repair pass before anything is saved.
A FastAPI service for document images: invoices, receipts, IDs, bills of lading. It prepares the image, asks the model for the exact JSON you define and repairs broken output on its own. Discord uploads are saved as a row in Google Sheets; API calls get the JSON back for n8n, Make or a CRM.
A fictional plumbing invoice (3 line items, VAT, a bill-to address) sent through an n8n form to the API with a custom JSON schema.
A row in the Google Sheet 6.7 seconds later: invoice number, date, supplier, bill-to, every line item with quantity and amount, subtotal, VAT and the £340.20 total. All correct, 893 tokens. A wrong API key and a link to a private address were both refused, with a ping on Discord.
The same call works from n8n, Make or a CRM: send the image, get the fields back, write them where the client needs them.
The same rules I check in every health check, and how this system handles them.
If the model returns broken JSON, the service sends it back for a repair pass before anything is saved.
Rate limits are retried with exponential backoff and random jitter. File downloads retry 3 times.
Results that need a human check are marked ⚠ in Discord, with the unclear fields flagged.
API key on every batch call. Image links that point to private networks are refused.
JSON logs with a trace ID and the token use of every request.
Agencies whose clients still type invoices, receipts or forms into a sheet or CRM by hand.