Skip to main content

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

  1. Publishes the configuration file (config/instructor.php) using the instructor-config publish tag
  2. Checks for API key configuration by scanning your .env file for OPENAI_API_KEY or ANTHROPIC_API_KEY entries
  3. Displays next steps including how to create your first response model and test the installation
If no API keys are detected, the command displays a warning with instructions for adding them.

Options

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

  1. Displays current configuration — connection name, driver, model, and a masked version of the API key
  2. Makes a test API call — either a structured output extraction (default) or a raw inference call
  3. Verifies the response — confirms the result contains the expected data
For the structured output test, the command extracts a simple name-and-age pair from a test sentence. For the inference test, it sends “Reply with just the word ‘pong’” and checks the response.

Options

Examples

Example Output

Use the -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 with StructuredOutput::with(responseModel: ...) immediately.

Arguments

Options

Examples

Basic Response Model

Creates app/ResponseModels/PersonData.php:

Collection Response Model

Creates a model with an array of typed items, plus a companion item class in the same file:

Nested Objects Response Model

Creates a model with nested Contact and Address objects:

With Description

Creates a model with the specified description replacing the TODO placeholder in the docblock.

Customizing Stubs

Publish the stubs to customize the templates used by make:response-model:
This copies stubs to stubs/instructor/ in your application root:
The command checks for published stubs first, falling back to the package defaults only when no custom stub is found.

Stub Placeholders


Creating Custom Commands

Build your own Artisan commands that use the facades for domain-specific extraction tasks:

Command Reference