PHPackages                             evoware/ollama-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. evoware/ollama-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

evoware/ollama-php
==================

A PHP library for interacting with local Ollama server.

v0.3.0(2y ago)241.7k5[3 issues](https://github.com/evowareio/ollama-php/issues)[1 PRs](https://github.com/evowareio/ollama-php/pulls)GPL-3.0-or-laterPHPPHP ^8.1CI failing

Since Apr 3Pushed 1y ago4 watchersCompare

[ Source](https://github.com/evowareio/ollama-php)[ Packagist](https://packagist.org/packages/evoware/ollama-php)[ RSS](/packages/evoware-ollama-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (9)Used By (0)

Ollama PHP
==========

[](#ollama-php)

A comprehensive PHP library designed for seamless interaction with the Ollama server, facilitating a range of operations from generating text completions to managing models and producing embeddings.

**But what's Ollama?**Ollama is a tool for running open-source Large Language Models locally. You can find more information about Ollama directly at the project [repository](https://github.com/ollama/ollama) or [documentation page](https://github.com/ollama/ollama/blob/main/docs/README.md).

Installation
------------

[](#installation)

To integrate the Ollama PHP Adapter into your project, use Composer for a smooth installation process:

```
composer require evoware/ollama-php
```

Usage:
------

[](#usage)

The Ollama PHP Adapter simplifies the complexity of interacting with the Ollama server, providing intuitive methods for various functionalities.

### Generating Text Completions

[](#generating-text-completions)

Generate text completions by providing a prompt to the model. Access the completion text using the getResponse() method:

```
use GuzzleHttp\Client as HttpClient;
use Evoware\OllamaPHP\OllamaClient;

$ollamaClient = new OllamaClient(new HttpClient());

$response = $ollamaClient->generateCompletion('The capital of France is ', ['model' => 'mistral:7b']);
$completionText = $response->getResponse(); // Returns the generated completion text.
```

#### Interacting with models:

[](#interacting-with-models)

Manage your local models by listing, pulling, and interacting through the provided methods:

```
// List all local models
$models = $ollamaClient->model()->list();

// Pull a local model
$result = $ollamaClient->model()->pull('mistral:7b');

// Alternatively, access via the getModelRepository method
$result = $ollamaClient->getModelRepository()->pull('mistral:7b');

// Load a Modelfile
$ollamaClient->fromModelFile('/path/to/modelfile');
```

To learn more about model file format, please visit Ollama Model File documentation [here](https://github.com/ollama/ollama/blob/main/docs/modelfile.md).

#### Generating embeddings:

[](#generating-embeddings)

Produce embeddings for a given text, returning an array of embedding data through the `EmbeddingsResponse` object:

```
$embeddings = $ollamaClient->generateEmbeddings('This is my text to be embedded.', 'nomic-embed-text');
```

### Response Types

[](#response-types)

The adapter delineates responses into specific object types for clarity and ease of use:

- **CompletionResponse**: Handles the data from text completion requests.
- **ChatCompletionResponse**: Manages chat completion data.
- **EmbeddingsResponse**: Encapsulates embedding data.
- **ModelOperationResponse**: Represents the outcome of model operations (create, delete, pull, etc.).

Responses provide access to the underlying Guzzle Response via the `getHttpResponse()` method for further customization and handling.

Roadmap
-------

[](#roadmap)

- Handling streaming responses.
- Introduction of ChatSession class for storing chat context in a styructured manner.
- Laravel facade support

Caution
-------

[](#caution)

⚠️ Development Stage: This project is in its early development stages and is not recommended for production environments. It is provided as-is, without any guarantees. Proceed with caution and use at your own risk. ⚠️

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance24

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

768d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fa0be685b6450d77c5978288f2638e9a477c3ed954bec3721ffbf37cf7696231?d=identicon)[evoware](/maintainers/evoware)

---

Top Contributors

[![evowareio](https://avatars.githubusercontent.com/u/141511188?v=4)](https://github.com/evowareio "evowareio (21 commits)")

---

Tags

gptlibraryllmollamaollama-apiphp

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/evoware-ollama-php/health.svg)

```
[![Health](https://phpackages.com/badges/evoware-ollama-php/health.svg)](https://phpackages.com/packages/evoware-ollama-php)
```

###  Alternatives

[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
