All posts
JSON mode and structured outputs — a field guide
Engineering 7 min read· 25 Jul 2026· By Engineering

JSON mode and structured outputs — a field guide

Response format, JSON schema, and the tradeoffs between them.

Two flavors of structured output. Pick the right one for the job.

response_format: json_object#

Loose — the model returns valid JSON but any shape it likes. Fast, cheap, and enough for exploratory work.

json
{"response_format": {"type": "json_object"}}

response_format: json_schema#

Strict — you provide a schema and the decoder is constrained to it. Zero parsing errors in production.

json
{
  "response_format": {
    "type": "json_schema",
    "json_schema": { "name": "invoice", "schema": {...}, "strict": true }
  }
}
Strict schemas cost a fraction more input tokens but eliminate parse-fail retries. Almost always worth it.

Ready to build?

Grab a key, keep your OpenAI SDK, and pay in INR.

Start free