PHPackages                             vormkracht10/laravel-embeddings - 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. vormkracht10/laravel-embeddings

ActiveLibrary[API Development](/categories/api)

vormkracht10/laravel-embeddings
===============================

Create embeddings for your Eloquent models to use with OpenAI

v0.1.1(4d ago)82.2k↓54.1%1MITPHPPHP ^8.2CI passing

Since May 15Pushed 4d ago2 watchersCompare

[ Source](https://github.com/ux-nl/laravel-embeddings)[ Packagist](https://packagist.org/packages/vormkracht10/laravel-embeddings)[ Docs](https://github.com/vormkracht10/laravel-embeddings)[ GitHub Sponsors](https://github.com/vormkracht10)[ RSS](/packages/vormkracht10-laravel-embeddings/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (2)Dependencies (22)Versions (10)Used By (0)

Create embeddings for your Eloquent models to use with OpenAI
=============================================================

[](#create-embeddings-for-your-eloquent-models-to-use-with-openai)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0f8a26160c84cd8e197605202340babfb15c9452efd865403a24912cb802dbd1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766f726d6b726163687431302f6c61726176656c2d656d62656464696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vormkracht10/laravel-embeddings)[![GitHub Tests Action Status](https://camo.githubusercontent.com/927056b831dfe5ed218f52c9568455be417e6339f467085108fc8b092a229ea2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766f726d6b726163687431302f6c61726176656c2d656d62656464696e67732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/vormkracht10/laravel-embeddings/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0414d698fca1e9bdfeabd54b0817761bf5043fd8bbd9257509a070900cad9734/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f766f726d6b726163687431302f6c61726176656c2d656d62656464696e67732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/vormkracht10/laravel-embeddings/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1778e9d4256f556e64103c1decc69c55f709a48f1856b761936d84098f80b93e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766f726d6b726163687431302f6c61726176656c2d656d62656464696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vormkracht10/laravel-embeddings)

OpenAI's text embeddings measure the relatedness of text strings. Using this package you can save embeddings automatically for your Eloquent model in a PostgreSQL vector database. To use the embeddings in your AI requests to the OpenAI API endpoints.

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

[](#installation)

You can install the package via composer:

```
composer require vormkracht10/laravel-embeddings
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-embeddings-migrations"
php artisan migrate
```

You can publish the config file with:

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

This is the contents of the published config file:

```
return [
    'enabled' => env('EMBEDDINGS_ENABLED', true),
    'driver' => env('EMBEDDINGS_DRIVER', 'null'), // 'null' / 'openai'
    'queue' => true,
    'database' => [
        'connection' => env('EMBEDDINGS_DATABASE_CONNECTION', 'pgsql'),
        'table' => env('EMBEDDINGS_DB_TABLE', 'embeddings'),
    ],
    'openai' => [
        'key' => env('OPENAI_API_KEY'),
        'model' => env('OPENAI_EMBEDDING_MODEL', 'text-embedding-ada-002')
    ],

    /*
    |--------------------------------------------------------------------------
    | Chunk Sizes
    |--------------------------------------------------------------------------
    |
    | These options allow you to control the maximum chunk size when you are
    | mass importing data into the embed engine. This allows you to fine
    | tune each of these chunk sizes based on the power of the servers.
    |
    */
    'chunk' => [
        'embeddable' => 500,
        'unembeddable' => 500,
    ],
];
```

Fill in the following env variables

```
EMBEDDINGS_DRIVER=openai
OPENAI_API_KEY=
```

Usage
-----

[](#usage)

```
// Add the Embeddable trait to your Model(s).
class MyModel {
    use Embeddable {
        \Laravel\Scout\Searchable::usesSoftDelete insteadof \Vormkracht10\Embedding\Embeddable;
    }
}

// You can override the embeddable content
class MyModel {
    // ...
    public function toEmbeddableString()
    {
        return strip_tags(implode(', ', $this->toArray()));
    }
}
```

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)

- [Vormkracht10](https://github.com/vormkracht10)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance99

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52% 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 ~155 days

Recently: every ~194 days

Total

6

Last Release

4d ago

PHP version history (2 changes)v0.0.1PHP ^8.1

v0.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c6a425dc8645907a118a007438172d58c2016773f54ab3a834beff172632f13?d=identicon)[ux](/maintainers/ux)

---

Top Contributors

[![Casmo](https://avatars.githubusercontent.com/u/385764?v=4)](https://github.com/Casmo "Casmo (39 commits)")[![markvaneijk](https://avatars.githubusercontent.com/u/1925388?v=4)](https://github.com/markvaneijk "markvaneijk (26 commits)")[![Baspa](https://avatars.githubusercontent.com/u/10845460?v=4)](https://github.com/Baspa "Baspa (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")[![Ynitial](https://avatars.githubusercontent.com/u/35238373?v=4)](https://github.com/Ynitial "Ynitial (1 commits)")

---

Tags

aiapichatgptembeddingsgptlaravelopenaiphpvector-databaselaravelvormkracht10

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/vormkracht10-laravel-embeddings/health.svg)

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M102](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816334.1k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[lettermint/lettermint-laravel

Official Lettermint driver for Laravel

1190.2k1](/packages/lettermint-lettermint-laravel)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1123.7k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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