Quickstart
Start processing your data with LLMs in under 5 minutes
Setup Your Development Environment
Set up LLM provider API keys - create .env
file in the root of your project and add the following:
NOTE: You can get your LLM provider API key from the provider’s dashboard, e.g.: OpenAI
You can also use API key directly in your code - see example.
Install Instructor with Composer
Installing Instructor is simple. Run following command in your terminal, and you’re on your way to a smoother data handling experience!
Basic example
This is a simple example demonstrating how Instructor retrieves structured information from provided text (or chat message sequence).
Response model class is a plain PHP class with typehints specifying the types of fields of the object.
Create file instructor-test.php
with the following content:
Now, you can run you example:
NOTE: Instructor supports classes / objects as response models. In case you want to extract simple types like strings, integers, float, booleans or enums, you need to wrap them in Scalar adapter. See section: Extracting Scalar Values.