Structured Output in Pipelines
Use structured output with AI pipelines for type-safe, composable workflows. Combine the power of runnables with guaranteed data structures for robust AI applications.
🚀 Quick Start
🏗️ Structured Output Flow
Basic Pipeline with Structured Output
// Define your data structure
class Person {
property name="firstName" type="string";
property name="lastName" type="string";
property name="age" type="numeric";
}
// Create pipeline with structured output
pipeline = aiModel( "openai" )
.structuredOutput( new Person() )
// Run and get typed result
person = pipeline.run( "Extract: John Doe, age 30" )
println( person.getFirstName() ) // "John"🔧 Pipeline Methods
.structuredOutput( schema )
.structuredOutput( schema ).structuredOutputs( schemas )
.structuredOutputs( schemas ).schema( jsonSchema )
.schema( jsonSchema )Message Templates with Structured Output
Chaining with Transformations
Multi-Step Pipelines
Working with Arrays
Parallel Processing
Streaming with Structured Output
Integration with AI Agents
Memory with Structured Data
Advanced Patterns
Conditional Structured Output
Validation Pipeline
Enrichment Pipeline
Aggregate Pattern
Best Practices
1. Position Structured Output at Output Stage
2. Use Transform for Post-Processing
3. Type Your Pipeline Variables
4. Cache Pipelines
Error Handling
Schema Validation Errors
Runtime Errors
Performance Tips
1. Batch Processing
2. Simple Schemas
3. Streaming for Long Responses
Related Documentation
Last updated