Structured Output
Get type-safe, validated responses from AI using BoxLang classes, struct templates, or JSON schemas. Eliminate manual parsing with automatic data extraction.
📋 Table of Contents
Why Use Structured Output?
🔄 Data Extraction Flow
Quick Start
📊 Class vs Struct Template
Using a Class
Using a Struct Template
Extracting Arrays
Multiple Schemas
With Conversations
With Tools
Manual Population with aiPopulate()
Comparison: Structured Output vs JSON Return Format
Feature
Structured Output
JSON Return Format
Provider Support
Provider
Support
Notes
Best Practices
1. Keep Schemas Simple
2. Use Descriptive Property Names
3. Handle Missing Data
4. Cache Pipelines with Structured Output
Error Handling
Next Steps
Last updated