Ollama PHP Client

Local LLMs from PHP 7.2+

A typed PHP client for a local Ollama server: text generation, embeddings and streaming without forcing a platform rewrite.

Architecture · AI Systems · LLM · PHP

Problem

PHP applications, including ones still on 7.2, needed a clean way to call Ollama for generation and embeddings. Most LLM SDKs assume a modern runtime and a cloud API.

Role

Author and maintainer

Approach

Built a domain-driven client: transport, generation and embedding as separate layers, DTOs at the boundary, cURL underneath. Composer package tenqz/ollama.

Outcome

Open-source library that lets an existing PHP backend talk to local models — generate, embed, stream — while keeping the application in charge of its own architecture.

The constraint was the same as with Qdrant: the interesting PHP systems are often the ones that cannot jump to a new language or PHP version in one step. Ollama already runs locally. The missing piece was a client that fits a PHP 7.2+ codebase.

The library does not wrap “AI” as a product. It talks to an API: prompt, options, embeddings, stream. Generation and embedding are separate domains. Transport is replaceable. That keeps the model on the other side of a contract the application can own.

GitHub

Let's make the complex understandable.

Architecture, engineering leadership, and AI in development — when the system is too important to simplify, and too expensive not to own.

LinkedIn Telegram Email