PHPackages                             dmsemenov/openai-attribute - 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. dmsemenov/openai-attribute

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

dmsemenov/openai-attribute
==========================

Allow to fill model attribute from OpenAi response.

v1.2.3(2y ago)098MITPHPPHP ^8.1

Since Jul 18Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (4)Versions (7)Used By (0)

Laravel OpenaiAttribute
=======================

[](#laravel-openaiattribute)

[![GitHub license](https://camo.githubusercontent.com/b8964c141170533da7dc761e94720d5b8cb351e99dacf423f8b7964cb657f6ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727576656e74732f72756e65742d69642d7068702d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/dmsemenov/openai-attribute/blob/master/license.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/4a8d573ddf5d1cb37c786def62d9527104d3d25b8208c1cd6641f64e86109c4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646d73656d656e6f762f6f70656e61692d6174747269627574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dmsemenov/openai-attribute)[![Total Downloads](https://camo.githubusercontent.com/651bd52ebecad05b18157af5d9bea7279913c8021b87c0b048d458b647d45856/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646d73656d656e6f762f6f70656e61692d6174747269627574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dmsemenov/openai-attribute)

Laravel package that allows to define ChatGPT generated attributes for Laravel model like description or other "text" attribute.

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

[](#installation)

- Install package

```
 composer require dmsemenov/openai-attribute
```

- Add your OpenAI api key `OPENAI_API_KEY` to `.env`. Key can be found here:

Configuration
-------------

[](#configuration)

Publish config if needed:

```
 php artisan vendor:publish --provider="Dmsemenov\OpenaiAttribute\OpenaiAttributeServiceProvider"
```

It is possible to specify request options in published config or in the model `generatedAttributes()` method.
Available request options see at [OpenApi documentation page](https://platform.openai.com/docs/api-reference/chat/create).

```
    // OpenAI api key
    'api_key' => env('OPENAI_API_KEY'),

    // Queue name for generate attributes jobs
    'queue_name' => env('OPENAI_QUEUE_NMAE', 'openai_generate'),

    // Default options for api chat completions requests.
    'default_options' => [
        'model' => env('OPENAI_API_MODEL', 'gpt-3.5-turbo'),
        'temperature' => 0.3,
        'max_tokens' => 100,
        'top_p' => 1.0,
        'frequency_penalty' => 0.0,
        'presence_penalty' => 0.0
    ],
```

Usage
-----

[](#usage)

Trait `HasGeneratedAttributes` should be added to model. it contains list of model attributes with prompt and options (if needed, see default\_options):

```
public function generatedAttributes(): array
{
    return [
        'description' => [
            'prompt' => 'Tell info about [model:name]". Wrap each paragraph to tag ',
            'max_tokens' => 1000
        ],

        'slug' => [
            'prompt' => 'Generate slug from [model:name]',
            'max_tokens' => 10
        ],
    ];
}
```

Models that fits condition in `[MyModel]->NeedsGenerateAttributes()` will be selected for attributes generation. Default: all.

Artisan commands to generate attributes:

```
php artisan openai:generate App\\Models\\[MyModel] --queued
```

or generate instantly without queue option:

```
php artisan openai:generate App\\Models\\[MyModel]
```

or specify model ids list:

```
php artisan openai:generate App\\Models\\[MyModel] --ids=1 --ids=2
```

Other useful commands:

```
Display queue size:
php artisan queue:monitor openai_generate

Remove jobs from queue:
php artisan queue:clear --queue=openai_generate

Run workers:
php artisan queue:work --queue=openai_generate
```

Change log
----------

[](#change-log)

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

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Dmitry Semenov](https://github.com/dmsemenov)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

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

Total

6

Last Release

952d ago

### Community

Maintainers

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

---

Top Contributors

[![dmsemenov](https://avatars.githubusercontent.com/u/4534689?v=4)](https://github.com/dmsemenov "dmsemenov (7 commits)")

---

Tags

eloquent-openai-attributelaravellaravel-chatgptlaravel-openailaravelOpenaiAttribute

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dmsemenov-openai-attribute/health.svg)

```
[![Health](https://phpackages.com/badges/dmsemenov-openai-attribute/health.svg)](https://phpackages.com/packages/dmsemenov-openai-attribute)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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