Artisan Commands
The package registers three Artisan commands to help with installation, testing, and scaffolding. All commands are registered automatically when the application is running in console mode.instructor:install
Sets up the Instructor package in your Laravel application. This is the recommended first step after installing the Composer package.What It Does
- Publishes the configuration file (
config/instructor.php) using theinstructor-configpublish tag - Checks for API key configuration by scanning your
.envfile forOPENAI_API_KEYorANTHROPIC_API_KEYentries - Displays next steps including how to create your first response model and test the installation
Options
| Option | Description |
|---|---|
--force | Overwrite existing configuration files (passed through to vendor:publish) |
Example Output
instructor:test
Tests your Instructor installation and API configuration by making a real API call. This verifies that your API key is valid, the network connection works, and the full extraction pipeline (or raw inference pipeline) is operational.What It Does
- Displays current configuration — connection name, driver, model, and a masked version of the API key
- Makes a test API call — either a structured output extraction (default) or a raw inference call
- Verifies the response — confirms the result contains the expected data
Options
| Option | Description |
|---|---|
--connection= | Test a specific configured connection instead of the default |
--inference | Test raw inference instead of structured output extraction |
Examples
Example Output
-v flag for verbose output, which includes a full stack trace if the test fails.
make:response-model
Generates a new response model class with typed constructor properties, docblock descriptions, and the correct namespace. The generated class is ready to use withStructuredOutput::with(responseModel: ...) immediately.
Arguments
| Argument | Description |
|---|---|
name | The name of the response model class (e.g., PersonData, InvoiceDetails) |
Options
| Option | Description |
|---|---|
--collection, -c | Create a collection response model with a parent class containing an array of child item objects |
--nested, -n | Create a nested response model with child object properties (Contact, Address) |
--description=, -d | Set the class docblock description (defaults to a TODO placeholder) |
--force, -f | Overwrite an existing file |
Examples
Basic Response Model
app/ResponseModels/PersonData.php:
Collection Response Model
Nested Objects Response Model
With Description
Customizing Stubs
Publish the stubs to customize the templates used bymake:response-model:
stubs/instructor/ in your application root:
Stub Placeholders
| Placeholder | Description |
|---|---|
{{ namespace }} | The fully qualified namespace for the class |
{{ class }} | The class name |
{{ description }} | The class description (from --description or the default TODO) |
Creating Custom Commands
Build your own Artisan commands that use the facades for domain-specific extraction tasks:Command Reference
| Command | Description |
|---|---|
instructor:install | Install and configure the package |
instructor:test | Test API configuration with a real API call |
make:response-model | Generate a response model class |