PHPackages                             tredmann/php-ollama - 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. tredmann/php-ollama

ActiveLibrary

tredmann/php-ollama
===================

v1.0.1(1y ago)341↓100%MITPHPPHP ^8.3

Since Jan 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tredmann/php-ollama)[ Packagist](https://packagist.org/packages/tredmann/php-ollama)[ RSS](/packages/tredmann-php-ollama/feed)WikiDiscussions main Synced today

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

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

[](#php-ollama)

PHP Client Library to interact with Ollama API.

The intention is to work with models on your Ollama setup and not the create a delete models. Therefore, this library will not implement any APIs to create, move or delete models. Here is a list of the APIs we intend to implement and the status of the implementation:

- Completion (without streaming support)
- Chat Completion (without streaming support)
- List local models
- Show Model Information
- List Running Models
- Version

The checkout the [Ollama API Docs](https://github.com/ollama/ollama/blob/main/docs/api.md) for more information and the APIs we might miss.

This package contains some low-level API libraries as well as a convenient API wrapper for all APIs.

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

[](#installation)

```
composer install tredmann/php-ollama
```

Convenience Wrapper
-------------------

[](#convenience-wrapper)

The easiest way to ask the LLM things is to use the convenience wrapper:

```
use Ollama\Ollama;

$ollama = new Ollama(model: 'gemma2:latest');

echo $ollama->completion(prompt: 'What is the capitol of Germany?');
// The capital of Germany is **Berlin**.
```

It does have a ton of limitations, but for quick results it is easy to use. I would highly encourage to look into the low-level library.

General way of working with the low-level library
-------------------------------------------------

[](#general-way-of-working-with-the-low-level-library)

### Creating the Client

[](#creating-the-client)

```
use Ollama\Client\OllamaClient;

$client = new OllamaClient(
    baseUrl: 'http://localhost:11434' // default
    );
```

### Inject the client into the respected API

[](#inject-the-client-into-the-respected-api)

```
use Ollama\Api\Completion;

$completionApi = new Completion(client: $client);
```

### Use the API by creating an API request

[](#use-the-api-by-creating-an-api-request)

```
use Ollama\Requests\CompletionRequest;

$request = new CompletionRequest(
    model: 'phi3.5:latest',
    prompt: 'What is the capitol of Germany?'
);
```

### Use a request to query the API

[](#use-a-request-to-query-the-api)

```
$response = $completionApi->getCompletion(request: $request);
```

### Use the response

[](#use-the-response)

```
echo $response->response;
// 'The capitol of Germany is Berlin.'
```

###  Health Score

32

—

LowBetter than 74% of packages

Maintenance44

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~3 days

Total

2

Last Release

435d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce62843fe1df789ccf6cd74730b2c56b8b0a173e4df76fd3762cc6188126844d?d=identicon)[tobias.redmann](/maintainers/tobias.redmann)

---

Top Contributors

[![balt-technologies](https://avatars.githubusercontent.com/u/49306158?v=4)](https://github.com/balt-technologies "balt-technologies (14 commits)")[![tredmann](https://avatars.githubusercontent.com/u/2635078?v=4)](https://github.com/tredmann "tredmann (14 commits)")

---

Tags

ollamaollama-apiollama-clientollama-phpphpphp8

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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