PHPackages                             floriandomgjoni/laravel-ai-factory - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. floriandomgjoni/laravel-ai-factory

ActiveLibrary[Testing &amp; Quality](/categories/testing)

floriandomgjoni/laravel-ai-factory
==================================

Laravel package for generating realistic factory data using AI (OpenAI, Gemini, DeepSeek) with support for manual and hardcoded fields, model events, and bulk inserts.

19251[1 issues](https://github.com/fdomgjoni99/laravel-ai-factory/issues)[2 PRs](https://github.com/fdomgjoni99/laravel-ai-factory/pulls)PHPCI passing

Since Nov 24Pushed 1mo agoCompare

[ Source](https://github.com/fdomgjoni99/laravel-ai-factory)[ Packagist](https://packagist.org/packages/floriandomgjoni/laravel-ai-factory)[ RSS](/packages/floriandomgjoni-laravel-ai-factory/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Laravel AI Factory
==================

[](#laravel-ai-factory)

Laravel AI Factory is a developer-friendly package for generating realistic test data using AI models. It integrates seamlessly with Laravel factories and supports both AI-generated and manually defined fields, with the option to use bulk or individual inserts.

🚀 Features
----------

[](#-features)

- ✅ Generate factory data using AI prompts
- ✅ Supports OpenAI - Gemini and DeepSeek support coming soon...
- ✅ Mix AI-generated fields with hardcoded or Faker-generated fields
- ✅ Optional bulk insert for performance (without triggering model events)
- ✅ Easy to extend and override

📦 Installation
--------------

[](#-installation)

```
composer require floriandomgjoni/laravel-ai-factory
```

⚙️ Configuration
----------------

[](#️-configuration)

Publish the config:

```
php artisan vendor:publish --tag=ai-factory-config
```

Update your `.env` with the appropriate API keys:

```
AI_FACTORY_DRIVER=openai
AI_FACTORY_OPENAI_API_KEY=your-api-key
AI_FACTORY_OPENAI_MODEL=gpt-4o-mini
```

or, for a local LLM:

```
AI_FACTORY_DRIVER=local
AI_FACTORY_LOCAL_URL=http://localhost:8080/v1/chat/completions
AI_FACTORY_LOCAL_API_KEY=""
AI_FACTORY_LOCAL_MODEL=Default
```

🧠 Defining AI Fields
--------------------

[](#-defining-ai-fields)

In your factory, use the `HasAIFactory` trait and define the `aiFields()` method:

```
