PHPackages                             drupalninja/drupalx\_ai - 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. drupalninja/drupalx\_ai

ActiveDrupal-module[Utility &amp; Helpers](/categories/utility)

drupalninja/drupalx\_ai
=======================

Provides AI-powered features including a chatbot and landing page generation.

2.x-dev(6mo ago)53.2k—0%11GPL-2.0-or-laterPHP

Since Oct 3Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/nextagencyio/drupalx_ai)[ Packagist](https://packagist.org/packages/drupalninja/drupalx_ai)[ RSS](/packages/drupalninja-drupalx-ai/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (1)

DrupalX AI Module
=================

[](#drupalx-ai-module)

Overview
--------

[](#overview)

The DrupalX AI module provides comprehensive AI-powered content generation features for Drupal sites. It leverages OpenAI-compatible APIs to generate dynamic content including paragraphs, images, and complete page layouts. The module is designed to work with paragraph-based content architecture and supports multiple image generation services.

Features
--------

[](#features)

- **AI-Powered Page Generation:** Generate complete landing pages with structured paragraph content using AI prompts.
- **Chatbot Widget:** A configurable block that allows users to describe content they want created, which then generates AI-powered page content.
- **Multiple Image Services:** Support for Pexels, Unsplash, and placeholder images for generated content.
- **Flexible Paragraph Support:** Works with paragraph entities to create rich, structured content layouts.
- **Drush Commands:** Command-line tools for generating pages programmatically.
- **Configurable AI Settings:** Full admin interface for configuring API endpoints, models, and prompts.
- **Content Validation:** Built-in validation services to ensure generated content meets Drupal standards.
- **Taxonomy Integration:** Automatic taxonomy term creation and assignment for generated content.

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

[](#requirements)

- Drupal ^9 or ^10
- PHP 8.1 or higher
- Composer
- The `drupal/key` module (for secure API key storage)
- The `nextagencyio/json_import` module (for structured content import)
- The `openai-php/client` Composer package (installed automatically)
- A content type configured for landing pages (typically 'landing')
- Paragraph types configured for the content structure you want to generate

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

[](#installation)

1. **Download the module:**Place the `drupalx_ai` module directory within your Drupal site's `modules/contrib` (or `modules/custom`) directory.
2. **Install dependencies:**Navigate to your Drupal root directory in the terminal and run:

    ```
    ddev composer require nextagencyio/drupalx_ai
    ```

    (If you are not using DDEV, run `composer require nextagencyio/drupalx_ai` directly.)
3. **Enable the module:**Enable the "DrupalX AI" module through the Drupal UI (Extend page) or by using Drush:

    ```
    ddev drush en drupalx_ai -y
    ```
4. **Clear Drupal's cache:**

    ```
    ddev drush cr
    ```

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

[](#configuration)

### API Configuration

[](#api-configuration)

1. **Create API Keys:**

    - Go to Configuration &gt; System &gt; Keys (`/admin/config/system/keys`)
    - Create keys for your AI service API (e.g., OpenAI, OpenRouter)
    - Optionally create keys for image services (Pexels, Unsplash)
2. **Configure AI Settings:**

    - Navigate to Configuration &gt; DrupalX AI Settings (`/admin/config/drupalx_ai/settings`)
    - Set your API endpoint URL (default: `https://openrouter.ai/api/v1`)
    - Configure your AI model name (default: `qwen/qwq-32b:free`)
    - Select your API key from the dropdown
    - Choose your preferred image service (Placeholder, Pexels, or Unsplash)
    - Configure image service API keys if using external services
3. **Customize AI Prompts:**

    - In the AI Settings form, expand "AI Prompt Settings"
    - Customize the system prompt to match your content generation needs
    - The prompt supports placeholders for allowed component types and sample data

### Content Type Configuration

[](#content-type-configuration)

The module works best with a content type configured for landing pages:

1. Create or configure a content type (typically named 'landing')
2. Add a paragraph reference field to store the generated content
3. Ensure appropriate paragraph types are created for the components you want to generate

### Chatbot Block

[](#chatbot-block)

1. Go to Structure &gt; Block layout (`/admin/structure/block`)
2. Choose a region and click "Place block"
3. Find "DrupalX AI Chatbot" in the list and place it
4. Configure the block settings as needed

The chatbot widget allows users to describe content they want created, and the AI will generate structured paragraph content based on their input.

Usage
-----

[](#usage)

### Drush Commands

[](#drush-commands)

#### Generate Page Command

[](#generate-page-command)

Create AI-generated landing pages from the command line:

```
ddev drush drupalx_ai:generate-page "Create a page about sustainable energy solutions for urban environments"
```

Or using the alias:

```
ddev drush dxp "A promotional page for a new tech startup focused on AI-driven analytics" --uid=1
```

Options:

- `--uid`: Specify the user ID to assign as the page author (defaults to current user or user 1)

### Chatbot Interface

[](#chatbot-interface)

Users can interact with the chatbot block to generate content by:

1. Typing a description of the content they want created
2. Submitting the form
3. The AI will process the request and create a new landing page with structured content

### API Integration

[](#api-integration)

The module supports various OpenAI-compatible APIs including:

- OpenAI GPT models
- OpenRouter (default configuration)
- Local LLM deployments
- Custom AI endpoints

Services and Architecture
-------------------------

[](#services-and-architecture)

The module provides several key services:

- **AIService:** Core service for interacting with AI APIs
- **ParagraphService:** Handles creation and management of paragraph entities
- **ValidationService:** Validates generated content and entity structure
- **MediaService:** Manages image and media file creation
- **TaxonomyService:** Handles automatic taxonomy term creation
- **ImageApiService:** Interfaces with external image services (Pexels, Unsplash)

File Structure
--------------

[](#file-structure)

- `src/Service/` - Core services for AI, paragraph, and media management
- `src/Form/` - Configuration forms for AI settings
- `src/Controller/` - AJAX controllers for chatbot functionality
- `src/Commands/` - Drush commands for content generation
- `src/Plugin/Block/` - Chatbot block plugin
- `files/` - Default prompts, sample data, and assets
- `templates/` - Twig templates for UI components

Customization
-------------

[](#customization)

### Custom Prompts

[](#custom-prompts)

You can customize the AI behavior by:

1. Modifying the system prompt in the AI Settings form
2. Editing the default prompt file at `files/default-system-prompt.txt`
3. Using the `{allowed_types}` and `{components_json}` placeholders in your prompts

### Custom Paragraph Types

[](#custom-paragraph-types)

The module can generate content for any paragraph types configured in your Drupal site. Configure the validation service to recognize your custom paragraph types and their fields.

### Custom Image Services

[](#custom-image-services)

Implement the `ImageApiServiceInterface` to add support for additional image services beyond Pexels and Unsplash.

Security Considerations
-----------------------

[](#security-considerations)

- API keys are securely stored using the Key module
- AJAX endpoints require appropriate permissions
- SSL verification can be configured per environment
- Generated content goes through validation before being saved

Troubleshooting
---------------

[](#troubleshooting)

- Check the Drupal logs for AI service errors
- Verify API keys are properly configured in the Key module
- Ensure the AI endpoint URL is accessible from your server
- Verify paragraph types and content types are properly configured
- Check that required permissions are granted to users

Development and Future Features
-------------------------------

[](#development-and-future-features)

The module provides a robust foundation for AI-powered content generation with plans for:

- Enhanced content type support
- Additional AI model integrations
- Advanced content customization options
- Multi-language content generation
- Integration with additional image and media services

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance66

Regular maintenance activity

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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

Every ~258 days

Total

2

Last Release

205d ago

Major Versions

1.x-dev → 2.x-dev2025-10-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/23e37b1ecb5973dbb1a3b1be781229da7602aee47963477ba49fcc353e3e04eb?d=identicon)[drupalninja](/maintainers/drupalninja)

---

Top Contributors

[![nextagencyio](https://avatars.githubusercontent.com/u/1112449?v=4)](https://github.com/nextagencyio "nextagencyio (155 commits)")

---

Tags

aidrupalopenaichatbot

### Embed Badge

![Health badge](/badges/drupalninja-drupalx-ai/health.svg)

```
[![Health](https://phpackages.com/badges/drupalninja-drupalx-ai/health.svg)](https://phpackages.com/packages/drupalninja-drupalx-ai)
```

###  Alternatives

[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[helgesverre/extractor

AI-Powered Data Extraction for your Laravel application.

22128.0k](/packages/helgesverre-extractor)[soukicz/llm

LLM client with support for cache, tools and async requests

445.6k](/packages/soukicz-llm)

PHPackages © 2026

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