PRODUCTION SCENARIO
Coralpoint Analytics extracts line items from 40-page invoices using a strict JSON schema with max_output_tokens set to 1,500. About 4% of responses fail JSON parsing with an unexpected end of input.
What should the client check before parsing the output text?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: Whether status is incomplete with an incomplete_details reason of max_output_tokens
Structured Outputs guarantees schema adherence only for a completed, non-refusal response, and a truncated generation returns status incomplete with an incomplete_details reason of max_output_tokens, so that is the check before parsing. The Responses API reports truncation through status rather than a finish reason, output_tokens reaching the cap is an inference rather than the reported reason, and a refusal arrives as its own property rather than as broken JSON.
Official Source: https://developers.openai.com/api/docs/guides/structured-outputs ↗