A PHP library for structured data extraction from LLMs, unified LLM API access, and building AI agents.
Instructor for PHP is a framework-agnostic toolkit that simplifies integrating Large Language Models (LLMs) into PHP applications. It provides a unified API for over 20 LLM providers and enables developers to extract strongly-typed, validated data from LLM outputs without writing boilerplate parsing code. The library transforms messy model outputs into typed PHP objects, arrays, or enums using simple class definitions.
PHP developers building applications that require structured data extraction from LLMs, such as those working on AI agents, data processing pipelines, or any system needing validated outputs from language models. It is particularly useful for teams using Laravel or Symfony, as it offers first-party framework integrations.
Developers choose Instructor for PHP because it eliminates the need to manually parse and validate LLM JSON responses, reducing boilerplate and errors. Its unique selling point is the combination of a unified API for multiple LLM providers with automatic validation, retry logic, and support for multiple output modes (JSON, JSON Schema, tool calling, markdown), all while remaining framework-agnostic.
Unified LLM API, structured data outputs with LLMs, and agent SDK - in PHP
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides a consistent interface for over 20 LLM providers like OpenAI, Anthropic, and Gemini, allowing developers to switch providers without rewriting request code, as demonstrated in the Polyglot inference examples.
Transforms LLM text outputs into typed PHP objects using simple class definitions, eliminating manual JSON parsing boilerplate, shown in the basic Person extraction example with type hints.
Validates extracted data against Symfony constraints and retries failed extractions with self-correction, reducing errors and improving reliability, as outlined in the validation and maxRetries sections.
Offers first-party Laravel and Symfony packages with facades, HTTP transport, and telemetry, making integration seamless for popular PHP frameworks without custom glue code.
Currently only supports Symfony validation constraints, limiting flexibility if your project uses other validation libraries or requires non-standard validation logic not covered by Symfony.
The project is a monorepo with many standalone packages, which can lead to dependency confusion and unnecessary overhead if you only need core structured extraction features.
The Symfony package is noted as 'currently being introduced,' indicating it might lack full stability or comprehensive documentation compared to the more established Laravel package.