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

ActiveLibrary[API Development](/categories/api)

halilcosdu/laravel-ollama
=========================

Laravel Ollama API Wrapper - Interact with the Ollama API

v0.0.2(2mo ago)268271[4 PRs](https://github.com/halilcosdu/laravel-ollama/pulls)MITPHPPHP ^8.2CI failing

Since Apr 23Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/halilcosdu/laravel-ollama)[ Packagist](https://packagist.org/packages/halilcosdu/laravel-ollama)[ Docs](https://github.com/halilcosdu/laravel-ollama)[ Fund](https://www.buymeacoffee.com/halilcosdu5)[ RSS](/packages/halilcosdu-laravel-ollama/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (13)Versions (8)Used By (0)

Laravel Ollama
--------------

[](#laravel-ollama)

[![Latest Version on Packagist](https://camo.githubusercontent.com/69ae6ec66a90db5d3c69df843818e04841ce6eee429e3600a2890dbe30f50c4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616c696c636f7364752f6c61726176656c2d6f6c6c616d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-ollama)[![GitHub Tests Action Status](https://camo.githubusercontent.com/788731cd5d97b43582793c917a5e5627c98979aea4cfd9d80b1745ce4279e495/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68616c696c636f7364752f6c61726176656c2d6f6c6c616d612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/halilcosdu/laravel-ollama/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/f2d7f18d8dc816861a1769917009a8e59f690af105d34a05085dc880df9648ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68616c696c636f7364752f6c61726176656c2d6f6c6c616d612f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/halilcosdu/laravel-ollama/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/52df3b65bb03186eacf4820470e0c97f7a3216afc556470d843c28251d723395/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616c696c636f7364752f6c61726176656c2d6f6c6c616d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-ollama)

Laravel Ollama is a PHP package that provides a simple and intuitive interface for interacting with the Ollama API. It is designed to be used with Laravel, a popular PHP framework, but can also be used in any PHP application. This package provides a set of methods for making requests to the Ollama API, including methods for setting the agent, prompt, model, format, options, and more. It also includes methods for handling responses from the API, such as retrieving the response in a specific format or streaming the response. With Laravel Ollama, you can easily integrate the Ollama API into your Laravel application and start making requests in a matter of minutes.
Features Easy configuration Fluent interface: Chain methods together to build your requests. Flexible Comprehensive: Covers all the endpoints of the Ollama API.

This package builds upon the foundational work provided by the Ollama Laravel package developed by [Cloud Studio](https://github.com/cloudstudio/ollama-laravel). Special thanks to them for their innovative approach and contributions to the Laravel community.

★ In the near future, I will add more features to this package.

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

[](#installation)

You can install the package via composer:

```
composer require halilcosdu/laravel-ollama
```

You can publish the config file with:

```
php artisan vendor:publish --tag="ollama-config"
```

This is the contents of the published config file:

```
return [
    'model' => env('OLLAMA_MODEL', 'llama3'),
    'url' => env('OLLAMA_URL', 'http://127.0.0.1:11434'),
    'default_prompt' => env('OLLAMA_DEFAULT_PROMPT', 'Hello world!'),
    'connection' => [
        'timeout' => env('OLLAMA_CONNECTION_TIMEOUT', 30),
    ],
];
```

Usage
-----

[](#usage)

```
@method static \HalilCosdu\Ollama\Ollama agent(string $agent): static
@method static \HalilCosdu\Ollama\Ollama getAgent(): string
@method static \HalilCosdu\Ollama\Ollama prompt(string $prompt): static
@method static \HalilCosdu\Ollama\Ollama getPrompt(): string
@method static \HalilCosdu\Ollama\Ollama model(string $model): static
@method static \HalilCosdu\Ollama\Ollama getModel()
@method static \HalilCosdu\Ollama\Ollama format(string $format): static
@method static \HalilCosdu\Ollama\Ollama getFormat(): string
@method static \HalilCosdu\Ollama\Ollama options(array $options = []): static
@method static \HalilCosdu\Ollama\Ollama getOptions(): array
@method static \HalilCosdu\Ollama\Ollama stream(bool $stream = false): static
@method static \HalilCosdu\Ollama\Ollama getStream(): bool
@method static \HalilCosdu\Ollama\Ollama raw(bool $raw): static
@method static \HalilCosdu\Ollama\Ollama getRaw(): bool
@method static \HalilCosdu\Ollama\Ollama models(): array
@method static \HalilCosdu\Ollama\Ollama show()
@method static \HalilCosdu\Ollama\Ollama copy(string $destination): static
@method static \HalilCosdu\Ollama\Ollama delete(): static
@method static \HalilCosdu\Ollama\Ollama pull(): static
@method static \HalilCosdu\Ollama\Ollama image(string $imagePath): static
@method static \HalilCosdu\Ollama\Ollama getImage(): ?string
@method static \HalilCosdu\Ollama\Ollama embeddings(string $prompt)
@method static \HalilCosdu\Ollama\Ollama getKeepAlive(): string
@method static \HalilCosdu\Ollama\Ollama keepAlive(string $keepAlive): static
@method static \HalilCosdu\Ollama\Ollama ask()
@method static \HalilCosdu\Ollama\Ollama chat(array $conversation)
@method static \HalilCosdu\Ollama\Ollama toArray(): array
@method static \HalilCosdu\Ollama\Ollama toJson($options = 0): false|string
```

Usage
-----

[](#usage-1)

### Basic Usage

[](#basic-usage)

```
use HalilCosdu\Ollama\Facades\Ollama;

$response = Ollama::agent('You are a weather expert...')
    ->prompt('Why is the sky blue?')
    ->model('llama3')
    ->options(['temperature' => 0.8])
    ->stream(false)
    ->ask();
```

### Vision Support

[](#vision-support)

```
$response = Ollama::model('llava:13b')
    ->prompt('What is in this picture?')
    ->image(public_path('images/example.jpg'))
    ->ask();

// "The image features a close-up of a person's hand, wearing bright pink fingernail polish and blue nail polish. In addition to the colorful nails, the hand has two tattoos – one is a cross and the other is an eye."
```

### Chat Completion

[](#chat-completion)

```
$messages = [
    ['role' => 'user', 'content' => 'My name is Halil Cosdu and I live in Turkey'],
    ['role' => 'assistant', 'content' => 'Nice to meet you , Halil Cosdu'],
    ['role' => 'user', 'content' => 'where I live ?'],
];

$response = Ollama::agent('You know me really well!')
    ->model('llama3')
    ->chat($messages);

// "You mentioned that you live in Turkey."
```

### Show Model Information

[](#show-model-information)

```
$response = Ollama::model('llama3')->show();
```

### Copy a Model

[](#copy-a-model)

```
Ollama::model('llama3')->copy('NewModel');
```

### Delete a Model

[](#delete-a-model)

```
Ollama::model('llama3')->delete();
```

### Generate Embeddings

[](#generate-embeddings)

```
$embeddings = Ollama::model('llama3')->embeddings('Your prompt here');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Halil Cosdu](https://github.com/halilcosdu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance85

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.1% 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 ~672 days

Total

2

Last Release

77d ago

### Community

Maintainers

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

---

Top Contributors

[![halilcosdu](https://avatars.githubusercontent.com/u/6373017?v=4)](https://github.com/halilcosdu "halilcosdu (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (1 commits)")

---

Tags

laravelHalilCosdularavel-ollama

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/halilcosdu-laravel-ollama/health.svg)

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.0k7.8M57](/packages/dedoc-scramble)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)

PHPackages © 2026

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