OpenAI strict JSON output fails to parse at end of input

OAI-SE Structured Outputs & Strict JSON Schemas Medium Question 14 of 24

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?

Show answer and explanation

AWhether 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.

Source: developers.openai.com/api/docs/guides/structured-outputs

Anonymous, no account needed. Your tally stays in this browser.

Next question Start 5 timed questions Browse all 24 original OAI-SE practice questions