Skip to main content
Guardrails supports streaming validation for structured data outputs, allowing you to validate JSON objects as they are generated by the LLM.

Setup

Install and import the necessary validators from Guardrails hub:

For structured JSON output

Define the prompt and output schema

Create the Guard object

Example: No streaming

By default, the stream parameter is set to False:
Output:

Example: With streaming

To enable streaming for structured data, set stream=True:
This allows you to see the structured data being validated in real-time as the LLM generates it, providing immediate feedback on validation results.