PHPackages                             juststeveking/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. [API Development](/categories/api)
4. /
5. juststeveking/ollama-php

ActivePackage[API Development](/categories/api)

juststeveking/ollama-php
========================

A PHP SDK for interacting with the Ollama API.

27828[2 issues](https://github.com/JustSteveKing/ollama-php/issues)[1 PRs](https://github.com/JustSteveKing/ollama-php/pulls)PHP

Since May 12Pushed 2y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Ollama PHP SDK
==============

[](#ollama-php-sdk)

The Ollama PHP SDK provides the easiest way to integrate [Ollama](https://github.com/jmorganca/ollama) with your PHP projects.

Getting Started
---------------

[](#getting-started)

```
composer require juststeveking/ollama-php

```

Usage
-----

[](#usage)

To get started with the Ollama SDK for PHP, firstly you will need to create a new SDK Instance. You can manually do this, or inject an instance of the SDK using a DI container.

```
use JustSteveKing\Ollama\SDK;

$sdk = (new SDK(
    apiToken: '',
    url: 'https://api.your-api-instance.test/',
))->setup();

// Now you can interact with the Ollama SDK.
```

API
---

[](#api)

There are a handful of methods you can call on the SDK, that will work directly with the Ollama API.

- `chat`: Generate the next message in a chat with a provided model. This is a streaming endpoint, so there will be a series of responses. Streaming can be disabled using "stream": false. The final response object will include statistics and additional data from the request.
- `create`: Create a model from a Modelfile. It is recommended to set modelfile to the content of the Modelfile rather than just set path. This is a requirement for remote create. Remote model creation must also create any file blobs, fields such as FROM and ADAPTER, explicitly with the server using Create a Blob and the value to the path indicated in the response.
- `generate`: Generate a response for a given prompt with a provided model. This is a streaming endpoint, so there will be a series of responses. The final response object will include statistics and additional data from the request.
- `pull`: Download a model from the ollama library. Cancelled pulls are resumed from where they left off, and multiple calls will share the same download progress.
- `push`: Upload a model to a model library. Requires registering for ollama.ai and adding a public key first.
- `delete`: Delete a model and its data.
- `list`: List models that are available locally.
- `embeddings`: Generate embeddings from a model

Chat with a provided model
--------------------------

[](#chat-with-a-provided-model)

```
use JustSteveKing\Ollama\SDK;
use JustSteveKing\Ollama\Enums\Role;
use JustSteveKing\Ollama\Requests\Chat;

$sdk = (new SDK(
    apiToken: '',
    url: 'https://api.your-api-instance.test/',
))->setup();

$sdk->chat(Chat::make([
  'model' => 'llama3',
  'messages' => [
    [
      'role' => Role::System,
      'content' => 'This is your system prompt.'
    ],
    [
      'role' => Role::User,
      'content' => 'This is your prompt.',
    ]
  ],
]));
```

This will return an instance of `ChatResponse`.

### Create a model from a Modelfile

[](#create-a-model-from-a-modelfile)

```
use JustSteveKing\Ollama\SDK;
use JustSteveKing\Ollama\Requests\CreateRequest;

$sdk = (new SDK(
    apiToken: '',
    url: 'https://api.your-api-instance.test/',
))->setup();

$sdk->create(CreateRequest::make([
  'model' => 'name of the model',
  'path' => 'Optional path to the modelfile',
  'modelfile' => 'String contents of the modelfile.',
  'stream' => false // Stream the response.
]));
```

This will return an instance of `StatusResponse`.

### Generate a response for a given prompt with a provided model

[](#generate-a-response-for-a-given-prompt-with-a-provided-model)

```
use JustSteveKing\Ollama\SDK;
use JustSteveKing\Ollama\Requests\Prompt;

$sdk = (new SDK(
    apiToken: '',
    url: 'https://api.your-api-instance.test/',
))->setup();

$sdk->generate(Prompt::make([
  'model' => 'llama3',
  'prompt' => 'This is your prompt',
]));
```

This will return an instance of `GenerateResponse`.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![JustSteveKing](https://avatars.githubusercontent.com/u/6368379?v=4)](https://github.com/JustSteveKing "JustSteveKing (3 commits)")

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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