Instructor can accept structured data as input, not just raw text. This enables powerful object-to-object transformations where the LLM acts as an intelligent mapping and enrichment layer between two data shapes.Documentation Index
Fetch the complete documentation index at: https://docs.instructorphp.com/llms.txt
Use this file to discover all available pages before exploring further.
Basic Usage
UsewithInput() to pass arrays or objects as input. Instructor serializes them into messages automatically.
Object-to-Object Transformation
The most common use case is transforming one object into another, using the LLM to interpret, translate, or enrich the data along the way.prompt parameter provides instructions for how to transform the data.
Array Input
Arrays work the same way. This is useful when your source data comes from a database query, API response, or form submission.String Input
Plain strings are also accepted. In this case,withInput() behaves the same as withMessages().
When to Use Structure-to-Structure
This pattern is most valuable when:- Translating or localizing structured content while preserving the data shape
- Enriching existing data with LLM-generated content (e.g., adding descriptions, summaries, or tags)
- Mapping between different schemas, using the LLM to handle ambiguity that rule-based mapping cannot
- Normalizing messy or inconsistent structured data into a clean format