PHPackages                             darvis/laravel-ai-generator - 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. darvis/laravel-ai-generator

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

darvis/laravel-ai-generator
===========================

AI content generation service for Laravel applications with OpenAI support

v1.0.0(3mo ago)02MITPHPPHP ^8.2CI failing

Since Jan 27Pushed 3mo agoCompare

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

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

Laravel AI Generator
====================

[](#laravel-ai-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/433cb5e918872e31d3488d7555b2ae82a53c2973d06aef42aa39a94f3a0914ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461727669732f6c61726176656c2d61692d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/darvis/laravel-ai-generator)[![PHP Version](https://camo.githubusercontent.com/b9046fa707e204ecab43e8a140ca391bb5c343a4ccbbac1482c30294f8ea3690/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461727669732f6c61726176656c2d61692d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/darvis/laravel-ai-generator)[![License](https://camo.githubusercontent.com/de51ee49cb2cf31732226e706b8d70a4f1cc7ae7ca2040f6174acb4057edcfd8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6461727669732f6c61726176656c2d61692d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/darvis/laravel-ai-generator)

AI-powered content generation service for Laravel applications. Generate blog posts, articles, news items, and more with SEO optimization and optional image generation.

Features
--------

[](#features)

- 🤖 **OpenAI Integration** - Uses GPT models for high-quality content
- 📝 **Structured Output** - Title, intro, text, SEO title, SEO description
- 🖼️ **Image Generation** - Optional AI-generated hero images
- 🌍 **Multi-language** - Support for Dutch, English, German, French, and more
- 🎯 **SEO Optimized** - Automatic SEO title and meta description
- ⚙️ **Configurable** - Tone, reading level, max words, and more
- 🔌 **Driver-based** - Easy to extend with new AI providers

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.0+ or 12.0+
- OpenAI API key

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

[](#installation)

```
composer require darvis/laravel-ai-generator
```

Publish the configuration file:

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

Add your OpenAI API key to `.env`:

```
OPENAI_API_KEY=your-api-key-here
```

Quick Start
-----------

[](#quick-start)

```
use Darvis\LaravelAiGenerator\AiGenerator;
use Darvis\LaravelAiGenerator\ContentRequest;

$generator = app(AiGenerator::class);

$result = $generator->generate(new ContentRequest(
    topic: 'The benefits of Laravel for web development',
    language: 'en',
));

// Access the generated content
echo $result->title;           // "Why Laravel is the Best PHP Framework"
echo $result->intro;           // "Laravel has revolutionized..."
echo $result->text;            // "Introduction..."
echo $result->seoTitle;        // "Laravel Benefits | Web Development"
echo $result->seoDescription;  // "Discover why Laravel..."
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Darvis\LaravelAiGenerator\AiGenerator;
use Darvis\LaravelAiGenerator\ContentRequest;

$generator = app(AiGenerator::class);

$result = $generator->generate(new ContentRequest(
    topic: 'Your topic here',
));
```

### Full Options

[](#full-options)

```
$result = $generator->generate(new ContentRequest(
    topic: 'Sustainable packaging solutions',
    language: 'nl',                    // nl|en|de|fr...
    audience: 'business owners',       // Target audience
    tone: 'formal',                    // informal|neutral|formal
    readingLevel: 'expert',            // general|expert|simple
    keywords: ['eco-friendly', 'packaging', 'sustainable'],
    cta: 'Request a quote',            // Call to action
    brand: 'EcoPack BV',               // Brand name
    maxWords: 600,                     // Max words for main text
    includeImage: true,                // Generate image prompt
    imageStyle: 'photo',               // photo|illustration|flat|3d
    imageAspect: '16:9',               // 1:1|4:5|16:9
));
```

### Using the Facade

[](#using-the-facade)

```
use Darvis\LaravelAiGenerator\Facades\AiGenerator;

$result = AiGenerator::generate(new ContentRequest(
    topic: 'Your topic here',
));
```

### ContentResult Properties

[](#contentresult-properties)

```
$result->title;           // Generated title
$result->intro;           // 2-4 sentence introduction (plain text)
$result->text;            // Main content with HTML formatting
$result->seoTitle;        // SEO title (max 60 chars)
$result->seoDescription;  // Meta description (max 155 chars)
$result->imagePrompt;     // English prompt for image generation
$result->imageUrl;        // Generated image URL (if available)
$result->imageBase64;     // Generated image as base64 (if available)
$result->errorMessage;    // Error message (if any)

// Helper methods
$result->hasError();      // Check if there was an error
$result->hasImage();      // Check if image was generated
```

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

[](#configuration)

```
// config/ai-generator.php

return [
    'driver' => env('AI_GENERATOR_DRIVER', 'openai'),
    'default_language' => env('AI_GENERATOR_LANGUAGE', 'nl'),

    'defaults' => [
        'tone' => env('AI_GENERATOR_TONE', 'informal'),
        'reading_level' => env('AI_GENERATOR_LEVEL', 'general'),
        'max_words' => env('AI_GENERATOR_MAX_WORDS', 900),
    ],

    'drivers' => [
        'openai' => [
            'api_key' => env('OPENAI_API_KEY'),
            'base_url' => env('OPENAI_BASE_URL', 'https://api.openai.com/v1'),
            'model' => env('OPENAI_MODEL', 'gpt-4.1-mini'),
            'image_model' => env('OPENAI_IMAGE_MODEL', 'gpt-image-1'),
            'temperature' => env('OPENAI_TEMPERATURE', 0.7),
            'timeout' => env('OPENAI_TIMEOUT', 45),
        ],
    ],
];
```

Environment Variables
---------------------

[](#environment-variables)

VariableDefaultDescription`OPENAI_API_KEY`-Your OpenAI API key (required)`OPENAI_BASE_URL``https://api.openai.com/v1`OpenAI API base URL`OPENAI_MODEL``gpt-4.1-mini`Model for text generation`OPENAI_IMAGE_MODEL``gpt-image-1`Model for image generation`OPENAI_TEMPERATURE``0.7`Creativity level (0-1)`OPENAI_TIMEOUT``45`Request timeout in seconds`AI_GENERATOR_LANGUAGE``nl`Default content language`AI_GENERATOR_TONE``informal`Default tone of voice`AI_GENERATOR_LEVEL``general`Default reading level`AI_GENERATOR_MAX_WORDS``900`Default max wordsCreating Custom Drivers
-----------------------

[](#creating-custom-drivers)

Implement the `AiContentDriver` interface:

```
use Darvis\LaravelAiGenerator\Contracts\AiContentDriver;
use Darvis\LaravelAiGenerator\ContentRequest;
use Darvis\LaravelAiGenerator\ContentResult;

class AnthropicDriver implements AiContentDriver
{
    public function generate(ContentRequest $request): ContentResult
    {
        // Your implementation here
    }
}
```

Register in the service provider or config.

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
--------

[](#security)

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

Credits
-------

[](#credits)

- [Arvid de Jong](https://github.com/darvis)

License
-------

[](#license)

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

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance80

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/24c445b7580e09ff72b8340d1423886148c4c8a249d0a828c98285109e7e5663?d=identicon)[darvis](/maintainers/darvis)

---

Top Contributors

[![ArvidDeJong](https://avatars.githubusercontent.com/u/7394837?v=4)](https://github.com/ArvidDeJong "ArvidDeJong (1 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/darvis-laravel-ai-generator/health.svg)

```
[![Health](https://phpackages.com/badges/darvis-laravel-ai-generator/health.svg)](https://phpackages.com/packages/darvis-laravel-ai-generator)
```

###  Alternatives

[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[beyondcode/laravel-favicon

Create dynamic favicons based on your environment settings.

37345.5k](/packages/beyondcode-laravel-favicon)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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