PHPackages                             isapp/ai-spamdetector - 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. isapp/ai-spamdetector

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

isapp/ai-spamdetector
=====================

Protect your contact forms from spam and bots using AI. Lightweight, flexible, and powered by OpenAI GPT for smarter filtering.

1.0.0(11mo ago)011MITPHP

Since May 23Pushed 11mo agoCompare

[ Source](https://github.com/isap-ou/ai-spamdetector)[ Packagist](https://packagist.org/packages/isapp/ai-spamdetector)[ RSS](/packages/isapp-ai-spamdetector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (1)

AI SpamDetector
===============

[](#ai-spamdetector)

AI SpamDetector is a lightweight, framework-agnostic PHP library designed to intelligently detect spam in form submissions using OpenAI’s GPT models. It analyzes message content, user metadata, and email patterns to help you prevent unwanted or bot-generated form entries with minimal setup.

[![AI SpamDetector](https://camo.githubusercontent.com/0040753fa3121a272b36ca7508c8cc515069b261e942c0a1dfb2751e9f17482d/68747470733a2f2f7374617469632e697361702e6d652f61692d7370616d6465746563746f722e6a7067)](https://github.com/isap-ou/ai-spamdetector)[![Latest Version on Packagist](https://camo.githubusercontent.com/b3229bd4628c7cf8b8f3af53d121f5b1db43aede8084283ac91a44dce8e42ceb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69736170702f61692d7370616d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/isapp/ai-spamdetector)[![Total Downloads](https://camo.githubusercontent.com/49dd601973a5b2a5ce2fa405a159c45d501b4407e1f1cad912a72ed86cf3aaa1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69736170702f61692d7370616d6465746563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/isapp/ai-spamdetector)

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

[](#installation)

You can install the package via composer:

```
composer require isapp/ai-spamdetector
```

Basic Usage
-----------

[](#basic-usage)

```
use Isapp\AiSpamdetector\Client;use Isapp\AiSpamdetector\FormData;use Isapp\AiSpamdetector\SpamDetector;

$client = new Client(apiKey: getenv('OPENAI_API_KEY'), organization: getenv('OPENAI_ORGANIZATION'),model: 'gpt-4');
$detector = new SpamDetector(client: $client);

$form = new FormData(
    name: 'James Bond',
    email: 'freeprizes@cheapbiz.com',
    message: 'Click here for FREE cash!!!',
    userAgent: $_SERVER['HTTP_USER_AGENT'] ?? null,
);

$isNotSpam = $detector->analyze($form); // returns true if message is not spam
```

### Class: FormData

[](#class-formdata)

The `FormData` class acts as a structured container for submitted form data. It supports optional fields and omits `null` values when serialized to JSON.

#### Constructor

[](#constructor)

```
new FormData(
    string $email,
    string $message,
    ?string $name = null,
    ?string $firstName = null,
    ?string $lastName = null,
    ?string $phoneNumber = null,
    ?string $userAgent = null
)
```

#### Properties

[](#properties)

PropertyTypeDescription`name`?stringFull name (if not split into first/last)`firstName`?stringFirst name`lastName`?stringLast name`phoneNumber`?stringPhone number`email`?stringEmail address`message`stringThe message content`userAgent`?stringBrowser user-agent (optional)#### Methods

[](#methods)

- `toJson(): string`
    Serializes the form to JSON, skipping all `null` fields.

### Class: Client

[](#class-client)

The `Client` class is a lightweight wrapper around the official OpenAI PHP client. It simplifies authentication and allows you to specify a model.

#### Constructor

[](#constructor-1)

```
new Client(
    string $apiKey,
    ?string $organization = null,
    string $model = 'gpt-4'
)
```

#### Methods

[](#methods-1)

- `make(): \OpenAI\Client`
    Returns the underlying `openai-php/client` instance.
- `getModel(): string`
    Returns the currently configured OpenAI model (e.g., `gpt-4`).

These methods allow you to configure the client before making requests:

- `setApiKey(string $apiKey): static` - Sets a new OpenAI API key.
- `setModel(string $model): static` - Sets the model to be used (e.g. `gpt-4`, `gpt-3.5-turbo`).
- `setOrganization(?string $organization): static` - Sets the OpenAI organization ID (optional).
- `setProject(?string $project): static` - Sets the OpenAI project ID (optional).
- `setBaseUri(string $baseUri): static` - Sets a custom API base URI (default: `api.openai.com/v1`).

All setters return `$this`, allowing fluent configuration.

Contributing
------------

[](#contributing)

Contributions are welcome! If you have suggestions for improvements, new features, or find any issues, feel free to submit a pull request or open an [issue](https://github.com/isap-ou/ai-spamdetector/issues) in this repository.

Thank you for helping make this package better for the community!

License
-------

[](#license)

This project is open-sourced software licensed under the [MIT License](https://opensource.org/licenses/MIT).

You are free to use, modify, and distribute it in your projects, as long as you comply with the terms of the license.

---

Maintained by [ISAPP](https://isapp.be) and [ISAP OÜ](https://isap.me).
Check out our software development services at [isap.me](https://isap.me).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance50

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

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

Unknown

Total

1

Last Release

354d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bfb1eae1e3e43813da6740e5eaa39307a95db7561c2d27e7e8aa24233cdcbeb?d=identicon)[andrii-trush](/maintainers/andrii-trush)

---

Top Contributors

[![andrii-trush](https://avatars.githubusercontent.com/u/14265776?v=4)](https://github.com/andrii-trush "andrii-trush (4 commits)")

---

Tags

aichatgptform-submissionform-validationphpspam-detection

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/isapp-ai-spamdetector/health.svg)

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

###  Alternatives

[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[eliashaeussler/typo3-solver

Extension for TYPO3 CMS to extend TYPO3's exception handling with AI generated solutions

292.1k](/packages/eliashaeussler-typo3-solver)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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