APIIntermediateClaude API
Required fields only if the data is always in the source
A required field the document does not contain pushes Claude to invent the value: make it nullable and add an "unclear" enum.
Mark as required only what always exists in the source. For optional data, use a type that accepts null and say in the description that it is null when it does not appear. In categories add "other" (with a detail field) and "unclear": an honest label is worth more than a wrong category. The schema guarantees the JSON syntax, not that the values are correct.
Example
{
"category": {"type": "string", "enum": ["bug", "feature", "docs", "unclear", "other"]},
"category_detail": {"type": ["string", "null"], "description": "Detail if category is other or unclear"},
"invoice_date": {"type": ["string", "null"], "description": "null if it does not appear in the document"}
}