PHPackages                             dwoodard/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. dwoodard/laravel-ollama

ActiveLibrary[API Development](/categories/api)

dwoodard/laravel-ollama
=======================

A Laravel package for interacting with the Ollama API.

v1.0.1(1y ago)084MITPHPPHP ^7.4|^8.0|^8.3

Since Jan 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dwoodard/laravel-ollama)[ Packagist](https://packagist.org/packages/dwoodard/laravel-ollama)[ Docs](https://github.com/dwoodard/laravel-ollama)[ RSS](/packages/dwoodard-laravel-ollama/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Laravel Ollama
==============

[](#laravel-ollama)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fc5b5ad0a7dfb8807fdc0fbede3c66b3b5533458b0c4392a292aa33d42e1aeb8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64776f6f646172642f6c61726176656c2d6f6c6c616d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dwoodard/laravel-ollama)[![Total Downloads](https://camo.githubusercontent.com/e8411b0180098d5c76ccc20b4be9bca53ca806a35b564dfd9c481b6b0f06b73b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64776f6f646172642f6c61726176656c2d6f6c6c616d612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dwoodard/laravel-ollama)[![GitHub Actions](https://github.com/dwoodard/laravel-ollama/actions/workflows/main.yml/badge.svg)](https://github.com/dwoodard/laravel-ollama/actions/workflows/main.yml/badge.svg)

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.

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

[](#installation)

You can install the package via composer:

```
composer require dwoodard/laravel-ollama
```

```
// add config/laravel-ollama.php
php artisan vendor:publish --tag=laravel-ollama
```

Usage
-----

[](#usage)

```
 $ollama = Ollama::init([
        'prompt' => 'where are you?',
        'format' => null
    ])->generate();
```

```
$ollama = Ollama::init([
            'prompt' => 'tell me a story',
            'system' => 'you are a great storyteller',
            'format' => null,
        ])->generate();
```

Examples
--------

[](#examples)

Use the facade to generate a simple response:

```
$response = \Dwoodard\LaravelOllama\Facades\LaravelOllamaFacade::init([
    'model' => 'llama3.2:latest',
    'prompt' => 'why is the sky blue?',
])->generate();

echo $response['response']; // "The sky is blue because..."
```

```
$personSchema = [
        "type" => "object",
        "properties" => [
            "firstName" => ["type" => "string"],
            "lastName" => ["type" => "string"],
            "age" => ["type" => "integer", "minimum" => 20],
            "backstory" => ["type" => "string"],
            'details' => [
                'type' => 'object',
                'properties' => [
                    'height' => ['type' => 'integer'],
                    'weight' => ['type' => 'integer'],
                    'hairColor' => ['type' => 'string'],
                    'eyeColor' => ['type' => 'string'],
                ],
            ]
        ],
        "required" => [
            'firstName',
            'lastName',
            "age",
            "backstory"
        ]
    ];

    $ollama = Ollama::init([
        'prompt' => 'Create a fictional character profile with the following details:
                    1. A first name.
                    2. A last name.
                    3. An age (must be 20 or older).
                    Ensure the response strictly follows this JSON format:
                    {
                        "firstName": "John",
                        "lastName": "Doe",
                        "age": 30
                    } Respond using JSON.',
        'system' => 'You are a great storyteller. response strictly in JSON format without additional text.',
        'format' => json_encode($personSchema),
    ])->generate();

    return $ollama;
```

Set a specific model parameter:

```
$ollama = \Dwoodard\LaravelOllama\Facades\LaravelOllamaFacade::init(['model' => 'llama3.2:latest']);
echo $ollama->model; // "llama3.2:latest"
```

Handle a JSON schema-based response:

```
$personSchema = [
    "type" => "object",
    // ...existing code...
];

$ollama = \Dwoodard\LaravelOllama\Facades\LaravelOllamaFacade::init([
    'prompt' => 'Create a character profile strictly in JSON format',
    'format' => json_encode($personSchema),
])->generate();

// $ollama will be an array with validated JSON fields
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Dustin Woodard](https://github.com/dwoodard)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance46

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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 ~0 days

Total

2

Last Release

471d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ee24e478cce0c4762197a3c1d07c026221216c1ef0acd682ff63deaa2e388b3?d=identicon)[dwoodard](/maintainers/dwoodard)

---

Top Contributors

[![dwoodard](https://avatars.githubusercontent.com/u/77433?v=4)](https://github.com/dwoodard "dwoodard (18 commits)")

---

Tags

laravel-ollamadwoodard

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

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