Configuration Path
Overview¶
The structured-output package itself does not depend on a published configuration
path. At the package boundary, configuration is passed as typed objects
(LLMConfig, StructuredOutputConfig, StructuredOutputRuntime).
Configuration path resolution matters when you load LLM provider presets from YAML files. This page explains how that resolution works.
Preset-Based Configuration¶
Load a named preset to create an LLMConfig:
You can also pass an explicit base path:
Path Resolution Order¶
When no explicit base path is given, LLMConfig::fromPreset() searches the
following locations (in order) and uses the first one that exists:
config/llm/presets/-- project-level published presetspackages/polyglot/resources/config/llm/presets/-- monorepo locationvendor/cognesy/instructor-php/packages/polyglot/resources/config/llm/presets/-- Composer install (monorepo package)vendor/cognesy/instructor-polyglot/resources/config/llm/presets/-- Composer install (standalone package)
This means presets work automatically in most project layouts without any manual path configuration.
Environment Variable¶
You can set the INSTRUCTOR_CONFIG_PATHS environment variable in your .env file
to tell the broader InstructorPHP ecosystem where to find configuration files:
This variable is used by companion packages and the CLI tooling. The
structured-output package does not read it directly -- it relies on LLMConfig
preset resolution or explicit configuration objects.
Key Types at the Package Boundary¶
| Type | Purpose |
|---|---|
LLMConfig |
Provider connection settings (API URL, key, model, driver) |
StructuredOutputConfig |
Structured output behavior (output mode, retries, prompts) |
StructuredOutputRuntime |
Assembled runtime with inference provider and event handling |
If your application resolves presets from files, that resolution happens before these types are constructed. The structured-output package only sees the resulting typed objects.