Overview
Environment variables are used at provider configuration time, not in the structured-output API itself. Your application or preset loader reads the variables,LLMConfig resolves provider settings from them, and
StructuredOutputRuntime uses the resulting configuration object.
This keeps the package independent from any specific framework bootstrap process.
LLM Provider API Keys
Instructor supports many LLM providers. Configure the API keys for the ones you plan to use in your.env file:
Embedding Provider Keys
If you use embedding features (via companion packages), configure these as well:Web Service Keys
Scraping and web-related add-ons use their own API keys:Configuration Directory Path
TheINSTRUCTOR_CONFIG_PATHS variable tells the InstructorPHP ecosystem where to
find configuration files:
LLMConfig::fromPreset(),
which has its own path resolution logic (see Configuration Path).
How It Fits Together
LLMConfig can be constructed from environment
variables, hardcoded values, a framework service container, or any other source.
Security: Keep your .env file secure and never commit it to version control.
For production, use your platform’s secrets management system.