How do I catch wrong values in schema-valid AI extraction output?
Validate the API response and then reconcile its claims against your input. A string or integer can have the expected type and still describe the wrong receipt, amount, or currency.
Auf Deutsch lesenStep-by-step walkthrough
Create a scratch receipt record with an amount in cents, currency code, and a source-line reference. Decide which fields may be unavailable.
Prepare one normal receipt, one missing a currency symbol and one showing both the subtotal and total. Write the expected accept or review outcome next to each.
Inspect the response state before parsing its data. Keep incomplete outputs and refusals out of the same success path as validated records.
Compare the parsed values with the cited lines. Submit only an approved synthetic record through the staging import and verify the saved fields.
Free practice example
Try it offline: a restaurant receipt lists a $20.00 subtotal and a $22.40 final charge. A valid record can carry total_cents: 2000. Your reconciliation should reject that value even though the schema accepts the integer.
How to check your result
A correct total lands in staging exactly once. An absent currency and an incorrect subtotal sent as the total stay in review.
Questions you can work through
How should I store $22.40 for a downstream import?
Store 2240 cents and USD as separate fields. Convert cents for display after validation so formatting does not change the stored units.
Can I use a source quote without exposing an entire receipt?
Your local test can retain a line number or synthetic source ID. Look up the original within the authorized workspace rather than copying it into long-lived logs.
What happens when the response was cut off?
Read the completion state and hold the import. A retry can rerun the extraction against the same input only after you know the first attempt created no new record.
Who decides whether the airport receipt uses USD or CAD?
Use explicit source evidence or a documented business rule. A traveler’s location alone can be inconclusive, so queue ambiguous records for review.
How can a subtotal pass both JSON and type validation?
It is still an integer. The business check has to compare its assigned role with the original fields and their positions on the receipt.
How do I keep an API retry from recording the same expense twice?
Use an idempotent key based on your receipt identity at the write boundary. Before replaying, verify whether the earlier job completed that write.
How can refunds expose a brittle amount check?
A refund can be negative where an expense is positive. Create a separate fixture and validate the sign against the transaction class and original amount.
What should a rejected-output alert include?
Include a job ID, rule name, and stage such as missing evidence or unsupported currency. Keep the raw document within its approved access boundary.
How do I test a change to required fields?
Replay both current-format and earlier-format sample outputs. Check that the intended version is accepted and migration or review handles older records.
What is a good release check for the first real import?
Compare a limited, approved test batch to ground truth and count accepted, blocked and duplicate records. Proceed after the destination values match.
Frequently asked questions
Can I practice without a paid API call?
Yes. Copy the synthetic receipt and write two valid JSON examples with different totals. Run the decision rules by hand or in a local script.
Are structured outputs available for every model or schema feature?
Check the current API guide for model support and the supported schema subset before choosing a deployment configuration.
Should a manual reviewer correct data in the original document?
Preserve the evidence. Correct the extraction in its own record and log the approved value and reason.
Sources
Checked
Continue with the masterprompt
Original product files are in German. EUR 24.50 one-time.
Related guides
- How do I audit an AI search journey before rewriting my website?
- How do I write a forum reply that actually helps?
- How do I find the questions people ask before hiring a service?
- How do I edit a bylined article without losing the author's voice?
- How can I tell whether a student got a hinge question right for the right reason?
- How do I write an oral history when two relatives remember different dates?
- How do I correct a published statistic when the denominator was wrong?
- How do I keep a mystery scene fair about what the viewpoint character knows?
- How can I test a training video storyboard before booking a shoot?
- How do I trace a reversed decision across two sets of meeting minutes?
- How do I keep leading zeros when importing a CSV for shipping or inventory?
- How can I cut a speech to fit a hard stop and still land the ending?
- How do I correct a published LinkedIn post readers may have acted on?
- How do I fix a Google snippet that still shows my old pickup policy?
- Why doesn't the average of our two team percentages match the overall success rate?
- What should the alt text say when a product photo also acts as a link?
- How do I answer a behavioral interview question about a team win without overstating my role?
- How do I find open sales deals with no confirmed next step?
- How can I tell whether an original study actually supports my claim?
- How do I audit affiliate links that send readers to the wrong product or market?