Set up Instructor in your project and start processing data with LLMs
vendor/cognesy/instructor-php
directory:
.env-dist
- Environment variables for API keys and configuration paths/config/*.php
- Configurations of Instructor modules/prompts/*
- Prompt templates for generating structured data from text.env
file.
Open the .env
file in your project directory and set up API keys for the LLM providers you plan to use. You can find
the keys in the respective provider’s dashboard.
.env-dist
for other API keys Instructor uses in its default configuration files.
Settings::setPath('/path/to/config')
in your code.
But to make it easier you can just set the value in your .env
file. Settings
will pick it up automatically
from there. This way you don’t have to set it in every script.
INSTRUCTOR_CONFIG_PATHS
is set automatically if you use the Instructor CLI tool to publish assets.config
directoryresources
directory.env
file locationconfig/app.php
or create a dedicated service provider.
resources
directory.env
file locationvendor/cognesy/instructor-php/config
to config/instructor/
vendor/cognesy/instructor-php/prompts
to resources/prompts/
vendor/cognesy/instructor-php/.env-dist
file to .env
with environment variables-c, --target-config-dir=DIR
- Custom directory for configuration files (default: config/instructor
)-p, --target-prompts-dir=DIR
- Custom directory for prompt templates (default: resources/prompts
)-e, --target-env-file=FILE
- Custom location for .env file (default: .env
)-l, --log-file=FILE
- Optional log file path to track the publishing process--no-op
- Dry run mode - shows what would be copied without making changes.env
files, the tool will only add missing variables, preserving your existing file content, formatting and comments.