PHPackages                             borah/llm-port-laravel - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. borah/llm-port-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

borah/llm-port-laravel
======================

Wrapper around the most popular LLMs that allows drop-in replacement of large language models in Laravel.

1.0.7(1y ago)22.8k↓34.6%1MITPHPPHP ^8.2CI passing

Since Oct 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/BorahLabs/LLM-Port-Laravel)[ Packagist](https://packagist.org/packages/borah/llm-port-laravel)[ Docs](https://github.com/BorahLabs/llm-port-laravel)[ GitHub Sponsors](https://github.com/Borah)[ RSS](/packages/borah-llm-port-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (16)Versions (9)Used By (1)

LLM Port
========

[](#llm-port)

Wrapper around the most popular LLMs that allows drop-in replacement of large language models in Laravel.

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

[](#installation)

You can install the package via composer:

```
composer require borah/llm-port-laravel
```

You can publish the config file with:

```
php artisan vendor:publish --tag="llm-port-laravel-config"
```

This is the contents of the published config file:

```
return [
    'default' => env('LLMPORT_DEFAULT_DRIVER', 'openai'),
    'drivers' => [
        'openai' => [
            'key' => env('OPENAI_API_KEY'),
            'default_model' => env('OPENAI_MODEL', 'gpt-4o-mini'),
            'organization' => env('OPENAI_ORGANIZATION'),
            'base_uri' => env('OPENAI_BASE_URI'),
        ],
        'gemini' => [
            'key' => env('GEMINI_API_KEY'),
            'default_model' => env('GEMINI_MODEL', 'gemini-1.5-flash-latest'),
        ],
        'anthropic' => [
            'key' => env('ANTHROPIC_API_KEY'),
            'default_model' => env('ANTHROPIC_MODEL', 'claude-3-5-sonnet-20240620'),
        ],
        'replicate' => [
            'key' => env('REPLICATE_API_KEY'),
            'default_model' => env('REPLICATE_MODEL', 'meta/meta-llama-3-8b-instruct'),
            'poll_interval' => env('REPLICATE_POLL_INTERVAL', 100000),
        ],
        'groq' => [
            'key' => env('GROQ_API_KEY'),
            'default_model' => env('GROQ_MODEL', 'llama-3.1-8b-instant'),
        ],
        'nebius' => [
            'key' => env('NEBIUS_API_KEY'),
            'default_model' => env('NEBIUS_MODEL', 'meta-llama/Meta-Llama-3.1-8B-Instruct'),
        ],
    ],
];
```

Usage
-----

[](#usage)

```
use Borah\LLMPort\Facades\LLMPort;
use Borah\LLMPort\Enums\MessageRole;
use Borah\LLMPort\ValueObjects\ChatMessage;
use Borah\LLMPort\ValueObjects\ChatRequest;

$response = LLMPort::chat(new ChatRequest(
    messages: [
        new ChatMessage(role: MessageRole::System, content: 'You are an AI assistant that just replies with Yes or No'),
        new ChatMessage(role: MessageRole::User, content: 'Are you an AI model?'),
    ]
));

echo $response->id; // 'chatcmpl-...'
echo $response->content; // 'Yes'
echo $response->finishReason; // 'stop'
echo $response->usage?->inputTokens; // 5
echo $response->usage?->outputTokens; // 10
echo $response->usage?->totalTokens(); // 15
```

You can also choose the model to use:

```
use Borah\LLMPort\Facades\LLMPort;
use Borah\LLMPort\Enums\MessageRole;
use Borah\LLMPort\ValueObjects\ChatMessage;
use Borah\LLMPort\ValueObjects\ChatRequest;

$response = LLMPort::driver('openai')->using('gpt-4o-mini')->chat(new ChatRequest(
    messages: [
        new ChatMessage(role: MessageRole::System, content: 'You are an AI assistant that just replies with Yes or No'),
        new ChatMessage(role: MessageRole::User, content: 'Are you an AI model?'),
    ]
));
```

Or define a specific driver:

```
use Borah\LLMPort\Facades\LLMPort;
use Borah\LLMPort\Enums\MessageRole;
use Borah\LLMPort\ValueObjects\ChatMessage;
use Borah\LLMPort\ValueObjects\ChatRequest;

$response = LLMPort::driver('gemini')->chat(new ChatRequest(
    messages: [
        new ChatMessage(role: MessageRole::System, content: 'You are an AI assistant that just replies with Yes or No'),
        new ChatMessage(role: MessageRole::User, content: 'Are you an AI model?'),
    ]
));
```

The supported drivers are:

- `openai`: [OpenAI](https://openai.com/)
- `gemini`: [Gemini](https://ai.google.dev/)
- `anthropic`: [Anthropic](https://www.anthropic.com/)
- `replicate`: [Replicate](https://replicate.com/)
- `groq`: [Groq](https://groq.com/)
- `nebius`: [Nebius AI](https://nebius.ai/)

You can also create your own driver:

```
use Borah\LLMPort\Contracts\CanListModels;
use Borah\LLMPort\Contracts\CanStreamChat;
use Borah\LLMPort\Drivers\LlmProvider;
use Borah\LLMPort\Enums\MessageRole;
use Borah\LLMPort\ValueObjects\ChatMessage;
use Borah\LLMPort\ValueObjects\ChatRequest;

class MyAwesomeDriver extends LlmProvider implements CanListModels, CanStreamChat
{
    public function models(): Collection
    {
        return collect([
          new LlmModel(name: 'model-1'),
          new LlmModel(name: 'model-2'),
        ]);
    }

    public function chat(ChatRequest $request): ChatResponse
    {
        // Your implementation
    }

    public function chatStream(ChatRequest $request, Closure $onOutput): ChatResponse
    {
        // Your implementation

        // When you get the server event: `$onOutput($delta, $fullContent);`
    }

    public function driver(): ?string
    {
      return 'my_awesome_driver';
    }
}
```

```
use Borah\LLMPort\Facades\LLMPort;

LLMPort::register('my_awesome_driver', MyAwesomeDriver::class);
```

> The key that you define in `driver()` should be registered as a driver in the `llmport.php` config file.

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance44

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

Recently: every ~34 days

Total

8

Last Release

445d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dbfeba566942b72c1d32de4763a869cc7cb28f522dbb3ca555d48847a24c077?d=identicon)[RuliLG](/maintainers/RuliLG)

---

Top Contributors

[![RuliLG](https://avatars.githubusercontent.com/u/3358390?v=4)](https://github.com/RuliLG "RuliLG (23 commits)")

---

Tags

laravelBorahllm-port-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/borah-llm-port-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/borah-llm-port-laravel/health.svg)](https://phpackages.com/packages/borah-llm-port-laravel)
```

###  Alternatives

[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)

PHPackages © 2026

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