All posts

"Validate, don't trust: handling structured LLM output in TypeScript and Python"

The model returned clean JSON every time in development, so you shipped. Then production sent it something weird. Structured-output modes guarantee the shape of a response, never the truth of it — here is the validation discipline that keeps model output from corrupting your system, in both TypeScript and Python.

Category:

AI engineering

Posted by:

Ahmed

Tags:
  • #AIengineering
  • #TypeScript
  • #Python
  • #Reliability
Posted on:

13 July 2026

"Validate, don't trust: handling structured LLM output in TypeScript and Python"

There is a specific kind of bug that only appears after you ship an LLM feature. In development the model returned clean JSON every time, the demo worked, and the integration looked finished. Three weeks into production, an unusual input comes through, the model returns the amount as the string "twelve thousand" instead of a number, your parser throws, and the job dies quietly in a queue nobody is watching. Or worse — it doesn't throw, and the bad value lands in your database.

© 2026 Ahmed Fareed. All rights reserved.

LOADING