Available Output Formats
intoArray()
Returns extracted data as a plain associative array instead of an object.intoInstanceOf()
Uses one class for the schema definition and a different class for the output object.UserProfile, ensuring thorough extraction. The output is then hydrated into the simpler UserDTO. This is valuable when you want to separate API contracts from internal models, simplify complex extraction results, or decouple domain models from presentation layers.
intoSelfDeserializing()
Provides a custom object that controls its own deserialization from the extracted array. The object must implement theCanDeserializeSelf interface.
Scalar adapter for extracting single values.
Streaming with Output Formats
Output formats work with streaming as well. Partial updates are best-effort values in the selected output format; the completed value runs the same validation and transformation pipeline as synchronous extraction.Comparison
intoObject() is a deprecated compatibility alias for intoSelfDeserializing().
Common Patterns
Conditional Deserialization
Inspect data before choosing the target class.Multi-Layer Architecture
Use a rich domain model for extraction and a simplified DTO for your application layer.Pluggable Extraction
Instructor uses a pluggable extraction pipeline to convert raw LLM responses into canonical arrays. You can customize this pipeline on theStructuredOutputRuntime to support non-standard response formats. See JSON Extraction for details on the extraction pipeline and how to write custom extractors.