halilcosdu/laravel-ollama
A Laravel package for Ollama that provides a fluent, expressive API to interact with local LLMs. Run chat and completion requests, generate embeddings, stream responses, manage models, and keep AI workloads private in your Laravel app with simple configuration.
streamAsk() / streamChat() with lazy NDJSON streaming is the enabler for the UX patterns users actually notice — token-by-token chat responses, progressive summarization, live drafting. If a roadmap item depends on perceived latency, this release is the technical green light.format() accepting JSON Schema arrays is the most strategically useful item here. It converts an LLM from "prose generator" into a reliable data-producing component — classification, extraction, form-filling, routing, enrichment. This is what moves AI from a demo feature to something you can put behind a queue worker or an API contract.Adopt when most of the following hold:
Look elsewhere when:
For executives — one paragraph: We evaluated a Laravel-native client for Ollama, the local model runtime. The new release adds streamed responses and JSON-Schema-constrained output, so we can ship AI features that feel instant and return data we can validate rather than free-form text we have to parse and pray over. Because inference runs on our own infrastructure, it addresses data-residency concerns and removes per-token vendor cost, at the price of owning GPU capacity and accepting open-weight model quality. The package is small, tested, statically analyzed, and security-audited, so the integration risk is low — the real decision is operational, not technical: are we prepared to run model infrastructure, and is open-weight quality sufficient for the use cases on the roadmap? My recommendation is to greenlight a scoped pilot on one structured-output use case, measure quality against a hosted baseline, and make the infrastructure commitment on evidence rather than enthusiasm.
For engineering — the short version: This is not a framework or an abstraction layer; it is a typed client over the Ollama HTTP API with Laravel-shaped configuration and a test-friendly surface. The relevant capabilities are streamAsk() / streamChat() returning lazily-consumed NDJSON, format() taking a JSON Schema array for constrained decoding, and explicit exception types for server errors and malformed chunks — so your stream consumers get real failure signals instead of silent truncation. It supports Laravel 11, 12, and 13 and is CI-covered on PHP 8.5. Quality signals at v1.2.0: 31 tests / 41 assertions passing with only optional live-integration tests skipped, PHPStan clean, Composer validation and security audit clean. The README was rewritten to be practical, which matters for onboarding cost.
Honest caveats to state up front: the test count is modest and two tests are skipped, so live-behavior confidence depends on your own integration testing against a real Ollama instance. Streaming and structured output are the two areas most likely to break against model or runtime changes — pin your Ollama version and add contract tests for both. And the skipped live tests mean nobody has yet proven, in CI, that the stream and schema paths work end-to-end; that proof is on us before this goes near production traffic.
How can I help you explore Laravel packages today?