Download the PHP package halilcosdu/laravel-ollama without Composer

On this page you can find all versions of the php package halilcosdu/laravel-ollama. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ollama

Laravel Ollama

Latest Version on Packagist Total Downloads

A fluent, Laravel-native client for running AI locally with Ollama. Generate text, build conversations, stream tokens without buffering, enforce JSON schemas, call tools, create embeddings, use vision models, and manage the models on your Ollama server.

Why Laravel Ollama?

Requirements

Package Supported versions
PHP 8.2–8.5
Laravel 11.x, 12.x, 13.x
Ollama A reachable local or remote Ollama server

Laravel 13 requires PHP 8.3 or newer.

Installation

Install the package:

Laravel discovers the service provider and Ollama facade automatically. Optionally publish the configuration:

Configure your application in .env:

Text generation

ask() returns the decoded Ollama response as an array when streaming is disabled:

Available generation controls include agent(), prompt(), model(), format(), options(), raw(), stream(), and keepAlive().

Token streaming

streamAsk() and streamChat() open an Ollama NDJSON stream and lazily yield each decoded chunk. The complete response is never buffered in memory, making this suitable for long answers, console commands, queues, and streamed HTTP responses.

Stream chat content:

The generator throws HalilCosdu\Ollama\Exceptions\OllamaStreamException for malformed chunks and for errors reported in the stream. Because generators are lazy, the HTTP request begins when iteration starts.

Stream directly from a Laravel route

Chat

For vision chat, place base64-encoded image data in the relevant message's images array. The image() convenience method applies to text generation through ask().

Structured outputs

Pass json or an entire JSON Schema to format(). Use stream(false) for a single, easily validated JSON response and a low temperature for consistency.

Tool calling

Your application remains responsible for validating arguments, executing approved tools, and returning tool results to the conversation.

Vision

image() validates the path and sends the file as base64 data.

Embeddings

embeddings() targets Ollama's deprecated /api/embeddings endpoint and remains available only for backward compatibility. Prefer embed().

Model management and server information

API reference

Method Ollama endpoint Result
ask() POST /api/generate Array, or raw Guzzle response with stream(true)
streamAsk() POST /api/generate Generator yielding decoded chunks
chat($messages) POST /api/chat Array, or raw Guzzle response with stream(true)
streamChat($messages) POST /api/chat Generator yielding decoded chunks
embed($input) POST /api/embed Embedding response array
models() GET /api/tags Local models
ps() GET /api/ps Running models
version() GET /api/version Server version
show() POST /api/show Model details
pull() / push() POST /api/pull, /api/push Fluent instance
create($modelfile) POST /api/create Fluent instance
copy($destination) POST /api/copy Fluent instance
delete() DELETE /api/delete Fluent instance

Testing and quality

The default suite uses Laravel HTTP fakes and Guzzle mock streams, so it is deterministic and makes no network calls. To run the optional live smoke tests:

Changelog, contributing, and security

See security advisory page.

Credits

License

Laravel Ollama is open-source software licensed under the MIT license.


All versions of laravel-ollama with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package halilcosdu/laravel-ollama contains the following files

Loading the files please wait ...