# FerryAI — native AI inference for PHP

FerryAI runs ONNX, GGUF and RubixML models directly inside a PHP 8.3+ process through FFI, giving PHP applications chat, streaming, embeddings, RAG and vector search without a Python sidecar, HTTP microservice or Docker container.

FerryAI loads native shared libraries such as onnxruntime and llama.cpp directly through PHP's FFI extension, the same C APIs Python bindings use, instead of shelling out to a subprocess or running a separate Python service. This removes the HTTP round-trip and duplicated process memory of a typical Python sidecar setup, and lets model weights be shared across PHP workers.

Its ONNX backend handles embeddings, similarity, classification and moderation with CPU or GPU acceleration; its llama.cpp backend handles chat and token-by-token streaming, including JSON Schema output enforced through GBNF grammars rather than prompt engineering. A built-in model cache downloads from Hugging Face, verifies file hashes and applies an LRU eviction policy.

It is an early release (v0.1.1) with a stabilizing public API, tested with PHPStan and Psalm and hundreds of automated tests, and is released under the MIT license.

Website: https://github.com/MADEVAL/FerryAI
