typesafe-ai-php
PHP SDK for Jev with attribute-annotated result classes and fluent System One requests.
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
| Type | Question | Answers |
|---|---|---|
| Yes / no | Does this convey urgency? | Explicitly time-sensitive · not urgent |
| Choice | Which team should handle this? | billing · technical · sales |
How it works
- Create a client with createInstance.
- Define a result class with question attributes, or build a SystemOneRequest.
- Call evaluate or systemOne.
- 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-phpAt a glance
- Type
- Library
- Status
- beta
- Language
- PHP
- Runtime
- library (Composer)
- Has code
- yes
Use cases and integrations
How curated lists describe it
PHP ecosystem: A modern TypeSafe AI client and SDK, with result classes and classic requests
yibie/awesome-jevJev for PHP, TypeSafe AI PHP SDK.
hellogumbo/awesome-jevPHP client for the three primitives.
MrJev/awesome-jev
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 serverproductionTypeScriptAx, a DSPy-style multi-language LLM framework, listed with a native TypeSafe provider for Boolean, Choice, Score and raw Jev questions.
PluginproductionTypeScriptEffect TypeScript library whose @effect/ai-typesafe package maps classify, probability and rating operations to Jev questions.
ProjectproductionTypeScriptPHP monorepo whose Polyglot module adds a TypeSafe driver for typed Noul, Choice and Score decisions alongside LLM inference.
ProjectproductionPHPGo MCP server giving any client typed Jev decisions via OpenRouter or TypeSafe, with validated answers and no paid retries.
MCP serverproductionGoSimon Willison's LLM plugin that adds Jev as a model for yes/no, choice and score questions from the command line.
PluginproductionPython