Skip to main content

Overview

The cognesy/instructor-struct package works without any published configuration files. All structured-output behavior is controlled through typed configuration objects in code. When configuration files are present in a project, they typically serve the companion Polyglot package (provider presets) rather than the structured-output package itself.

Provider Presets

LLM provider connections are configured through YAML preset files managed by the cognesy/polyglot package. Each preset defines the API URL, driver, model, token limits, and other provider-specific settings:
You load a preset with LLMConfig::fromPreset():
The preset resolution searches several paths automatically (project config/ directory, monorepo paths, and Composer vendor paths), so presets work out of the box in most setups.

Configuration Groups

In the broader InstructorPHP ecosystem, configuration is organized into groups. Each group is stored in a separate file. The main groups are: The structured-output package only consumes the structured and llm groups. Other groups belong to companion packages.

Structured Output Configuration

Rather than reading from config files, the structured-output package uses the StructuredOutputConfig class directly:
This keeps the package independent from any file-based configuration system while still allowing integration with one when needed (via fromArray() or fromDsn()).