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

Abandoned → [ux-nl/laravel-embeddings](/?search=ux-nl%2Flaravel-embeddings)Library[API Development](/categories/api)

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

Create embeddings for your Eloquent models to use with OpenAI

v0.2.0(1mo ago)82.3k↓57.1%1[4 PRs](https://github.com/ux-nl/laravel-embeddings/pulls)MITPHPPHP ^8.2CI passing

Since May 15Pushed 1mo ago2 watchersCompare

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

READMEChangelog (3)Dependencies (33)Versions (11)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/4d4112e7d4f1d4cbe18d869af602c5ca7431b3fa63a5bee1526d456c9165c33c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75782d6e6c2f6c61726176656c2d656d62656464696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ux-nl/laravel-embeddings)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a12e5f8926d896e918d2cb8fefb389286b6ca31a8ac7de92e9b572bb453e3adf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f75782d6e6c2f6c61726176656c2d656d62656464696e67732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ux-nl/laravel-embeddings/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e2de1f55afb366a092ac292109151a45845222ee1e9526b0b512e397319b750c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f75782d6e6c2f6c61726176656c2d656d62656464696e67732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/ux-nl/laravel-embeddings/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e67ceda18d497b0971054f7e4d604e91c0a4ba1d184a95153e39ab9c4b49b443/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75782d6e6c2f6c61726176656c2d656d62656464696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ux-nl/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 ux-nl/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 \UX\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)

- [UX](https://github.com/ux-nl)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance92

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~191 days

Total

7

Last Release

41d 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 (28 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![Baspa](https://avatars.githubusercontent.com/u/10845460?v=4)](https://github.com/Baspa "Baspa (3 commits)")[![Ynitial](https://avatars.githubusercontent.com/u/35238373?v=4)](https://github.com/Ynitial "Ynitial (1 commits)")

---

Tags

aiapichatgptembeddingsgptlaravelopenaiphpvector-databaselaravelux-nl

###  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.2k12.6M141](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[backstage/mails

View logged mails and events in a beautiful Filament UI.

16429.7k](/packages/backstage-mails)[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.

5226.7k](/packages/simplestats-io-laravel-client)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[lettermint/lettermint-laravel

Official Lettermint driver for Laravel

11124.6k1](/packages/lettermint-lettermint-laravel)

PHPackages © 2026

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