Skip to content

typesafe-ai-php

PHP SDK for Jev with attribute-annotated result classes and fluent System One requests.

Librarybeta

Overview

typesafe-ai-php is a PHP client for TypeSafe's Jev, tested on PHP 8.2 and later and installed with Composer. You give it a state and typed questions and get one typed answer per question. There are three main objects: TypeSafeClient sends requests, SystemOneRequest holds state and questions with a fluent builder, and SystemOneResult maps answers back to question IDs.

The recommended style is result classes: annotate constructor parameters with Noul or Choice attributes, and evaluate returns an instance with each parameter filled with its answer. The key and base URL fall back to TYPESAFE_API_KEY and TYPESAFE_BASE_URL, matching the official JavaScript and Python SDKs. Token counts and the resolved model version are available through the lower-level systemOne call.

What the decision model decides

TypeQuestionAnswers
Yes / noDoes this convey urgency?Explicitly time-sensitive · not urgent
ChoiceWhich team should handle this?billing · technical · sales

How it works

  1. Create a client with createInstance.
  2. Define a result class with question attributes, or build a SystemOneRequest.
  3. Call evaluate or systemOne.
  4. Use typed answers in your PHP code.

Strengths

  • Attribute-based result classes map answers to typed properties.
  • Environment variable conventions match official SDKs.
  • Supports selecting models such as jev-preview.

Caveats

  • Requires a TypeSafe API key.
  • Community SDK.

Getting started

composer require sanmai/typesafe-ai-php

At a glance

Type
Library
Status
beta
Language
PHP
Runtime
library (Composer)
Has code
yes

Use cases and integrations

How curated lists describe it

Frequently asked questions

What PHP version is needed?

PHP 8.2 or later.

What are result classes?

Classes whose constructor parameters are annotated with questions; evaluate fills them with answers.

Can I change the endpoint?

Yes, through TYPESAFE_BASE_URL.

Related projects

  • Hack Club's lightweight LLM proxy, listed for adding a Jev forwarding endpoint behind its auth, limits and usage logging.

    MCP serverproductionTypeScript
  • 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
  • PHP monorepo whose Polyglot module adds a TypeSafe driver for typed Noul, Choice and Score decisions alongside LLM inference.

    ProjectproductionPHP
  • Go MCP server giving any client typed Jev decisions via OpenRouter or TypeSafe, with validated answers and no paid retries.

    MCP serverproductionGo
  • Simon Willison's LLM plugin that adds Jev as a model for yes/no, choice and score questions from the command line.

    PluginproductionPython