Skip to content

instructor-php

PHP monorepo whose Polyglot module adds a TypeSafe driver for typed Noul, Choice and Score decisions alongside LLM inference.

ProjectproductionMIT

Overview

Instructor PHP is a set of framework-agnostic PHP components: Instructor for structured output from LLMs, Polyglot for unified inference across providers, Retrieval for vector search and RAG context, and an Agent SDK, with Laravel and Symfony packages. It is aimed at PHP developers who want typed results from AI services without hand-parsing JSON.

Polyglot includes a typed decision API with a TypeSafe driver. Code such as Decision::using('typesafe') sends questions built from classes like Noul (and the other primitives) and returns typed answers, so a PHP application can call Jev through the same provider abstraction it uses for OpenAI, Anthropic, Gemini or Ollama. Drivers are pluggable, so other decision backends could be added. The project is MIT-licensed and documented on instructorphp.com.

What the decision model decides

TypeQuestionAnswers
Yes / noUser-defined yes/no question via Polyglot's Decision APIyes · no
ChoiceUser-defined choice question via Polyglot's Decision API(inferred)—

How it works

  1. Build a Questions collection with Noul, Choice or Score
  2. Call Decision::using('typesafe') with state and questions
  3. Polyglot's TypeSafe driver calls Jev
  4. Use typed answers in PHP code

Strengths

  • Jev available through the same provider abstraction as LLMs
  • Framework integrations for Laravel and Symfony
  • Custom drivers can add other decision backends

Caveats

  • Decision API is one small part of a large monorepo
  • Requires a TypeSafe API key for the TypeSafe driver

Getting started

See packages/polyglot/docs/decision/overview.md and examples/B06_Decisions/DecisionPrimitives/run.php in the repository.

At a glance

Type
Project
Status
production
Language
PHP
Runtime
library (Laravel, Symfony)
Has code
yes
License
MIT

Use cases and integrations

How curated lists describe it

Frequently asked questions

How does Instructor PHP use Jev?

Its Polyglot module has a TypeSafe driver for a typed Decision API with Noul, Choice and Score questions.

Can I switch decision providers?

Drivers are pluggable, so you can write your own.

Is it framework-specific?

No, it is framework-agnostic, with optional Laravel and Symfony packages.

Related projects

  • Ax, a DSPy-style multi-language LLM framework, listed with a native TypeSafe provider for Boolean, Choice, Score and raw Jev questions.

    PluginproductionTypeScript
  • Effect TypeScript library whose @effect/ai-typesafe package maps classify, probability and rating operations to Jev questions.

    ProjectproductionTypeScript
  • Elixir library for unified LLM calls across providers, with an evaluate interface that calls Jev via TypeSafe or OpenRouter.

    ProjectproductionElixir
  • Self-hosted multi-tenant AI agent platform listed as including optional TypeSafe client tools for classification, scoring and yes/no.

    LibraryproductionPython
  • Provider-agnostic TypeScript AI SDK; per list sources, an @tanstack/ai-typesafe adapter exposes Jev decisions through decide().

    ServiceproductionTypeScript
  • TypeSafe Jev provider for the SwiftDecision framework, returning validated probability distributions through its DecisionBackend protocol.

    ProjectbetaSwift