Blog
AITypeScriptOpenAI

Structured outputs from OpenAI: JSON your app can actually parse

Jafrix System 2026-01-08 8 min read

Why JSON mode and schemas beat prompt-level JSON instructions, and how we validate on the server before touching the DB.

If your app expects JSON, don't trust the model to improvise brackets. Use the API features that constrain output shape, then validate with Zod or similar on the server before you write to Postgres.

Structured outputs reduce parsing bugs more than clever prompts. A schema says "these keys, these types." The model still hallucinates values, but you stop getting parse errors that break the whole pipeline.

Always version your schema. When you add a field, ship it optional first, backfill, then require. Mobile clients lag store review by weeks.

Store raw model output for debugging when something goes wrong, but redact secrets. A short retention window on logs is enough for most products.

If the model returns something that fails validation, return a clear error to the user and don't retry in a tight loop. That is how you burn money and rate limits.

“Good systems are mostly boring parts wired together so they don’t fall over on a Tuesday night.”

Jafrix System

JS

Jafrix System

Director of Product Architecture

Designing deterministic systems in a non-deterministic world. Specialists in high-frequency trading engines and global SaaS infrastructure.