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)261.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 2y 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 today

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

28

—

LowBetter than 52% of packages

Maintenance18

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

814d 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

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M45](/packages/tencentcloud-tencentcloud-sdk-php)[guzzlehttp/guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

25711.0M191](/packages/guzzlehttp-guzzle-services)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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