marcreichel / laya-php
git clone https://github.com/marcreichel/laya-php.git
1.4.0 · 8d ago
Classify text in PHP without an LLM bill: typed decisions in 100+ languages, self-hosted. Laravel-ready SDK for Laya, a Jev AI alternative.
—
stars, 24h
—
stars, 7 days
+108
stars, 30 days · #2,120
108
★ total
3
forks · 1 open issues
Star history starts 2026-10-20; the chart appears after the second daily snapshot.
LanguagePHP
LicenseApache-2.0
Created2026-09-26 (23d ago)
Last push8d ago
Watchers4
OwnerUser
GitHub topics
aiclassificationdecision-enginedecision-modeljevjev-aijev-apilaravellayallmmultilingualnlpphppsr-18sdktext-classificationwrapperzero-shot
Links
- GitHub: github.com/marcreichel/laya-php
- Homepage: https://packagist.org/packages/marcreichel/laya-php
- Releases · Issues · Hacker News mentions
README excerpt
**Classify text in PHP without paying for an LLM API.** Route support tickets, spot churn risk and score urgency, in 100+ languages, on your own server, and get the answers back as typed enums, ints and bools. [code] - **Self-hosted:** the text never leaves your infrastructure, and you pay no per-token fees. - **Typed:** describe a decision as a readonly class with enums and get an instance back. - **Calibrated:** every answer has a confidence you can threshold on to send unsure cases to a human. - **Testable:** a built-in fake lets you unit-test without a running server. Under the hood this is an SDK for Laya, a multilingual decision engine that answers typed questions (`choice`, `score`, yes/no) about any text in a single forward pass. Laya runs in Python, so the SDK talks to `laya-serve`, Laya's HTTP server, over any PSR-18 client. **Looking for Jev?** `laya-serve` speaks the same `POST /v1/systemone` protocol as TypeSafe's hosted Jev API, with the same `choice`/`score`/`noul` answers, so this package is also a self-hosted Jev AI alternative for PHP. It targets `laya-serve`, and CI checks its requests and responses against TypeSafe's OpenAPI spec on every change and weekly, so other `/v1/systemone` servers such as sys1 work too. It hasn't been tested against the hosted Jev API itself. ## Installation [code] PHP 8.4+. You also need a PSR-18 HTTP client (Guzzle, Symfony HttpClient, …). The SDK finds the installed one automatically. To run `laya-serve` locally, use the `compose.yaml` in this repository (it pins upstream Laya to v0.4.6, commit `c73908d`) or follow Laya's Docker guide: [code] Runnable scripts are in `examples/`. Set `LAYA_URL` (and `LAYA_API_KEY`) if your server isn't on `localhost:8000`. `05-testing-with-fake.php` runs without a server. ### Laravel For Laravel 13+, the service provider is auto-discovered. It registers `Laya` as a singleton, configured from your `.env`: [code] `LAYA_TIMEOUT` and `LAYA_RETRIES` build the HTTP client with `symfony/http-client` (`composer require symfony/http-client`); setting either without it throws. To use your own client instead, bind `Psr\Http\Client\ClientInterface` in the container or put a service id in `laya.http_client`; it wins over both settings. With none of these set, the SDK discovers a PSR-18 client as before. `php artisan laya:health` prints the server's status and loaded checkpoints (plus the idle-unload window and idle time when laya-serve runs with `LAYA_IDLE_UNLOAD_SECONDS`, since an idle unload leaves "Loaded: none" on a healthy server), and exits with 1 when it is unreachable or unhealthy, so you can use it in deploy checks. `php artisan laya:try` runs a decision class on a piece of text and shows each parameter's question, hydrated value (`null` below `minConfidence`), answer confidence and the probability of every option, plus the routed checkpoint and a warning when the text was cut off. Use it to iterate on `#[Ask]` and `#[Describe]` wording: [code] It takes `--mod