Urgent.News

What's breaking now, across thousands of outlets.

More in AI

Getting reliable JSON from LLMs: schemas, validation, retries and a deterministic fallback

To get reliable structured data from an LLM, use four layers : ask for a JSON Schema (and use the provider's structured-output or tool-calling mode where available), validate the result in code with a…

  • Provide LLM with JSON schema to reduce malformed JSON
  • Validate response in code using schema library like Pydantic
  • Retry validation with error message, implement deterministic fallback if needed

More from Tuesday 17 November →