Skip to main content

Instructor for PHP

InstructorPHP is a modular AI toolkit for PHP 8.3 and later. Use a package on its own or combine packages according to your application’s needs.

Choose a package

  • Polyglot provides LLM inference, embeddings, streaming, and typed decision models through a shared PHP API.
  • Instructor extracts validated PHP objects from LLM responses.
  • Agents provides an agent loop with tools, state, and execution controls.
  • AgentCtrl orchestrates coding-agent CLIs from PHP.
Install the complete toolkit:
For structured extraction alone, install cognesy/instructor-struct. See the Instructor quickstart for the standalone setup.

First structured extraction

Set OPENAI_API_KEY in your environment, then run:
Credentials and model availability depend on your provider. Keep secrets outside source code and check the documentation for the version installed by Composer.

Documentation and community