Skip to main content
Instructor for PHP is a lightweight library that makes it easy to get structured outputs from Large Language Models (LLMs). Built on top of modern PHP 8.3+ features, it provides a simple, type-safe way to work with AI models.

Key Features

  • Type Safety: Full PHP 8.3+ type system support with strict typing
  • Multiple LLM Support: Works with OpenAI, Anthropic, Gemini, Cohere, and more
  • Validation: Built-in validation with custom rules and LLM-powered validation
  • Streaming: Real-time partial object updates for better UX
  • Function Calling: Native support for LLM function/tool calling
  • Zero Dependencies: Clean, lightweight implementation

Quick Example

Getting Started

Choose your path:

Architecture

This project consists of several modular packages:
  • Instructor - Main structured output library
  • Polyglot - Low-level LLM abstraction layer
  • HTTP Client - Flexible HTTP client for API calls
  • HTTP Pool - Concurrent request execution for fan-out workloads

Community


Instructor for PHP - Making AI outputs predictable and type-safe.