ux-nl/laravel-embeddings
Larablocks Analysis
ux-nl/laravel-embeddings works with Laravel 10 to 13 (latest release v0.2.0, Jul 9, 2026).
Recommendation checks
PromisingPromising: maintained and up to date, meets 2 of 4 checks; not yet widely used.
- Works with Laravel 13, the current version
- Released in the last 12 months (Jul 9, 2026)
- 312 downloads a month (needs 10,000)
- 9 GitHub stars (needs 100)
State
Actively maintained- Last stable release: Jul 9, 2026.
- 3 releases in the last 12 months.
- First released: May 15, 2024.
- Monthly downloads: 312.
- 4 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require ux-nl/laravel-embeddings |
|
| Latest Version: | v0.2.0 |
| PHP: | ^8.2 |
| Laravel: | 10 – 13 |
| License: | MIT |
| Last Updated: | Jul 9, 2026 |
| Links: | GitHub · Packagist |
Create embeddings for your Eloquent models to use with OpenAI
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
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
// 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
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| v0.2.0 | ^8.2 | MIT | |
| v0.1.1 | ^8.2 | MIT | |
| v0.1.0 | ^8.2 | MIT | |
| v0.0.4 | ^8.1 | MIT | |
| v0.0.3 | ^8.1 | MIT | |
| v0.0.2 | ^8.1 | MIT | |
| v0.0.1 | ^8.1 | MIT |