Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Ollama Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for AI features: This package is a thin, well-scoped Laravel client for Ollama, which means local/self-hosted LLM inference without per-token vendor spend. It directly informs the classic "integrate a hosted API vs. run models ourselves" decision — and lowers the cost of prototyping the self-hosted path.
  • Feature feasibility and scoping: 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.
  • Structured output as a product capability: 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.
  • Data residency and compliance positioning: Local inference via Ollama is a credible answer to "where does customer data go?" That is a sales/enablement decision, not just an engineering one, and it should be weighed explicitly against hosted-model quality.
  • Roadmap sequencing: The package's maturity (typed stream exceptions, PHPStan clean, Composer audit clean) means error-path handling does not have to be invented in-house. That shortens estimates for AI-adjacent epics and reduces the "unknown unknowns" padding PMs usually add.
  • Platform upgrade planning: Laravel 11/12/13 and PHP 8.5 coverage means adoption does not create a framework-upgrade blocker. That is a scheduling input for platform-teams, not a product differentiator.

When to Consider This Package

Adopt when most of the following hold:

  • You are Laravel-native. The value here is framework fit — configuration, facades/bindings, test-friendly ergonomics. On Symfony, plain PHP, or a polyglot service mesh, that advantage evaporates and a generic HTTP client is a better call.
  • You need local or private inference. Regulated data, air-gapped environments, cost sensitivity at high volume, or a hard requirement that prompts not leave your infrastructure.
  • You want structured, schema-validated output. Extraction and classification workloads where a malformed response is a bug, not a stylistic quirk.
  • You are building conversational or streaming UX. The lazy stream methods plus explicit exceptions for server errors and malformed chunks are exactly the surface you need to build resilient incremental rendering.
  • You are on a supported stack. Laravel 11+ and a PHP version within the tested matrix. Confirm PHP 8.5 CI coverage matches your actual deployment target rather than assuming it.

Look elsewhere when:

  • You need frontier-model quality. Ollama runs open-weight models; if your product's differentiation depends on the strongest available reasoning or long-context performance, a hosted provider is the right default and this package becomes a fallback or a dev-only tool.
  • You need embeddings, reranking, or multimodal pipelines as first-class features — verify coverage before committing; do not assume a chat-focused client handles them.
  • You need managed SLAs, autoscaling, or GPU capacity planning. This package talks to your Ollama instance. Someone must own that infrastructure, and that operational cost belongs in the build-vs-buy math.
  • Your team has no PHP/Laravel depth and the AI surface is a standalone service — a Python or TypeScript stack will have a richer ecosystem.
  • You are pre-product-market-fit and just need to validate an idea in a week. A hosted API with no infrastructure is faster to a signal; migrate to local inference once the unit economics or compliance demands it.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib