Core Features
Structured Output Extraction
Define a PHP class, get a populated object back:- Works with any PHP class with typed properties
- Supports nested objects and arrays
- Handles nullable fields gracefully
- Preserves type information throughout
Automatic Validation
Built-in support for Symfony Validator:- All Symfony validation constraints supported
- Custom validators work out of the box
- Validation errors trigger automatic retry
- Error messages sent to LLM for self-correction
Self-Correcting Retries
When validation fails, Instructor automatically retries:- LLM generates response
- Response validated against constraints
- On failure: errors sent back to LLM with context
- LLM attempts correction
- Repeat until valid or max retries reached
Input Flexibility
Text Input
Simple string input:Chat Messages
OpenAI-style message arrays:Image Input
Process images with vision-capable models:Structured Input
Pass objects or arrays as input:Output Modes
Tools Mode (Default)
Uses LLM function/tool calling:JSON Schema Mode
Strict schema enforcement:JSON Mode
Basic JSON response format:Markdown JSON Mode
Prompting-based extraction:Response Types
Single Object
Arrays of Objects
UseSequence::of() to extract lists:
Scalar Values
Extract simple types with adapters:Enums
Streaming
Partial Updates
Get incremental results as they arrive:Sequence Streaming
Stream sequence items as they complete:LLM Providers
Supported Providers
Provider Selection
Schema Definition
Type-Hinted Classes
PHP DocBlocks for Instructions
Attributes for Detailed Control
Dynamic Schemas with Structure
Advanced Features
Context Caching
Reduce costs with cached context (Anthropic):Custom Prompts
Override default extraction prompts:StructuredPromptRequestMaterializer uses Twig-backed prompt classes.
Configure mode-specific prompts with modePromptClasses, retry feedback with
retryPromptClass, and deserialization repair with
deserializationErrorPromptClass. The legacy inline modePrompts, retryPrompt,
and chatStructure settings and RequestMaterializer were removed in 2.7. When
prompt classes are insufficient, implement CanMaterializeRequest and inject it
through StructuredOutputRuntime::withRequestMaterializer().
Event System
Monitor internal processing:Debug Mode
See all LLM interactions:- Full request payloads
- Raw LLM responses
- Validation errors
- Retry attempts
Framework Integration
Laravel
Symfony
Standalone
Observability
Token Usage
Timing
Event-Based Logging
What’s Next
- Getting Started - Quick installation guide
- Why Instructor - Understanding the value proposition
- Use Cases - Industry-specific examples
- Cookbook - 60+ working examples
- API Reference - Complete documentation