PHPackages                             ogrre/laravel-chatgpt - 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. ogrre/laravel-chatgpt

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

ogrre/laravel-chatgpt
=====================

Library to add chat management for openai client

1.0.6(2y ago)3123MITPHPPHP ^8.1

Since Jun 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/0grre/laravel-chatGPT)[ Packagist](https://packagist.org/packages/ogrre/laravel-chatgpt)[ Docs](https://github.com/ogrre/laravel-chatgpt)[ RSS](/packages/ogrre-laravel-chatgpt/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (9)Dependencies (3)Versions (10)Used By (0)

🐈 Laravel Chat for ChatGPT
==========================

[](#-laravel-chat-for-chatgpt)

[![Packagist Version](https://camo.githubusercontent.com/235b4a4f434c2fcb0dbf799380bf9c359d2fc4c310228a2a122aa9ff54ba78cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f677272652f6c61726176656c2d63686174677074)](https://camo.githubusercontent.com/235b4a4f434c2fcb0dbf799380bf9c359d2fc4c310228a2a122aa9ff54ba78cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f677272652f6c61726176656c2d63686174677074)[![GitHub License](https://camo.githubusercontent.com/7380fe1cd0cfb90e9343f3cab9b055551ff666c733fe0f10a736734fd36bc8df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f30677272652f6c61726176656c2d63686174677074)](https://camo.githubusercontent.com/7380fe1cd0cfb90e9343f3cab9b055551ff666c733fe0f10a736734fd36bc8df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f30677272652f6c61726176656c2d63686174677074)[![Packagist Downloads](https://camo.githubusercontent.com/5b71f04f96eb59e36e7546d055ec686ccf91ad921ce95802da4441486e6ec3ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f677272652f6c61726176656c2d63686174677074)](https://camo.githubusercontent.com/5b71f04f96eb59e36e7546d055ec686ccf91ad921ce95802da4441486e6ec3ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f677272652f6c61726176656c2d63686174677074)

Documentation
-------------

[](#documentation)

This libray need openai php client, so don't forget to add in your .env this variables:

```
# .env

OPENAI_API_KEY=
OPENAI_API_ORGANIZATION=
OPENAI_MODEL=gpt-4
```

Installation:
-------------

[](#installation)

To install the Laravel Chat for ChatGPT library, run the following command:

```
composer require ogrre/laravel-chatgpt
```

After the installation, publish the vendor files by executing the command:

```
php artisan vendor:publish --provider="Ogrre\ChatGPT\ChatServiceProvider"
```

By default, the service provider will be automatically registered in the `app.php` file. However, if needed, you can manually add the service provider in the `config/app.php` file:

```
# config/app.php

'providers' => [
    // ...
    Ogrre\ChatGPT\ChatServiceProvider,
];
```

Finally, run the migration command to create the necessary database tables:

```
php artisan migrate
```

Usage instructions
------------------

[](#usage-instructions)

To associate a chat with a model, the model must use the `hasChat` trait. For example, in the User model:

```
class User extends Authenticatable
{
    use HasFactory, HasChat;
    // ...
}
```

Once the model is set up with the `hasChat` trait, you can create a new chat using the following command:

```
$optional_title = "Translate this word";
$optional_role = "You're a helpful assistant";

$user_chat = $user->newChat($optional_title, $optional_role);
```

After creating a new chat or retrieving an existing one, you have two options to interact with it:

Using the chat object directly:

```
$chat->gpt("say hello in French");
```

Using the model directly (in this example, the User model):

```
$user->chatgpt("say hello in French", $chat);
```

The Chat model is a standard Laravel Model, so you can use all the usual functions, including delete and others.

Additionally, the library provides a ChatResource for displaying chats in an API, allowing for easy integration with API endpoints.

Contributing
============

[](#contributing)

Contributions are welcome and will be fully credited. I accept contributions via Pull Requests on Github.

Support me
==========

[](#support-me)

[![Buy Me A Coffee](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/0grre)

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Recently: every ~47 days

Total

9

Last Release

958d ago

Major Versions

0.0.2 → 1.0.02023-06-27

PHP version history (2 changes)0.0.1PHP ^7.3|^8.0|^8.1

1.0.5PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d4c871c07ee63285d919d302d5789af131cf66cea09ad55802c95a1d536c01f?d=identicon)[0grre](/maintainers/0grre)

---

Top Contributors

[![ogrre](https://avatars.githubusercontent.com/u/59645891?v=4)](https://github.com/ogrre "ogrre (21 commits)")

---

Tags

chatchatgptcomposercomposer-librarylaravellaravel-librarylibraryopenaiopenai-apiopenai-librarypackagistphp

### Embed Badge

![Health badge](/badges/ogrre-laravel-chatgpt/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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