PHPackages                             moderyo/sdk - 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. [API Development](/categories/api)
4. /
5. moderyo/sdk

ActiveLibrary[API Development](/categories/api)

moderyo/sdk
===========

Official PHP SDK for Moderyo Content Moderation API

v2.0.7(4mo ago)10MITPHPPHP ^8.4CI passing

Since Feb 17Pushed 4mo agoCompare

[ Source](https://github.com/Moderyo/moderyo-php)[ Packagist](https://packagist.org/packages/moderyo/sdk)[ Docs](https://github.com/moderyo/moderyo-php)[ RSS](/packages/moderyo-sdk/feed)WikiDiscussions main Synced 1mo ago

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

Moderyo PHP SDK
===============

[](#moderyo-php-sdk)

Official PHP SDK for the Moderyo Content Moderation API.

[![PHP Version](https://camo.githubusercontent.com/0751c5c7ed417028d6909f393af80b98d84b224db16e8307c3988e7eefc8ecdb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d626c7565)](https://php.net)[![Packagist Version](https://camo.githubusercontent.com/e35e25769377e9ed401d61629d5c612e14815b60c276dfc300ed60a4f3e31b78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f646572796f2f73646b)](https://packagist.org/packages/moderyo/sdk)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

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

[](#requirements)

- PHP 8.4 or higher
- Guzzle HTTP 7.x

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

[](#installation)

```
composer require moderyo/sdk
```

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

[](#quick-start)

```
use Moderyo\ModeryoClient;

$client = new ModeryoClient('your-api-key');

$result = $client->moderate('Hello, this is a friendly message!');

if ($result->isBlocked) {
    echo "BLOCKED: " . ($result->policyDecision?->reason ?? 'Policy violation') . "\n";
} elseif ($result->isFlagged) {
    echo "FLAGGED for review\n";
} else {
    echo "ALLOWED\n";
}
```

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

[](#configuration)

### API Key String

[](#api-key-string)

```
$client = new ModeryoClient('your-api-key');
```

### API Key with Options

[](#api-key-with-options)

```
$client = new ModeryoClient('your-api-key', [
    'baseUrl'  => 'https://api.moderyo.com',
    'timeout'  => 60,
    'maxRetries' => 5,
]);
```

### ModeryoConfig Object

[](#moderyoconfig-object)

```
use Moderyo\ModeryoConfig;
use Moderyo\ModeryoClient;

$config = new ModeryoConfig([
    'apiKey'       => 'your-api-key',
    'baseUrl'      => 'https://api.moderyo.com',
    'timeout'      => 30,
    'maxRetries'   => 3,
    'retryDelay'   => 1.0,
    'defaultModel' => 'omni-moderation-latest',
]);

$client = new ModeryoClient($config);
```

### Environment Variables

[](#environment-variables)

```
// Set MODERYO_API_KEY and optionally MODERYO_BASE_URL
$client = ModeryoClient::fromEnv();
```

Moderation
----------

[](#moderation)

### Basic

[](#basic)

```
$result = $client->moderate('Text to check');

echo "Blocked: " . ($result->isBlocked ? 'Yes' : 'No') . "\n";
echo "Flagged: " . ($result->isFlagged ? 'Yes' : 'No') . "\n";
echo "Allowed: " . ($result->isAllowed ? 'Yes' : 'No') . "\n";
```

### With Options

[](#with-options)

```
$result = $client->moderate('Text to check', [
    'model'        => 'omni-moderation-latest',
    'longTextMode' => true,
    'mode'         => 'enforce',
    'risk'         => 'balanced',
]);
```

### Batch

[](#batch)

```
$batch = $client->moderateBatch(['Hello', 'Bad text', 'Spam']);
echo "Blocked: " . count($batch->getBlocked()) . "\n";
echo "Has blocked: " . ($batch->hasBlocked() ? 'Yes' : 'No') . "\n";
```

Error Handling
--------------

[](#error-handling)

```
use Moderyo\Exceptions\AuthenticationException;
use Moderyo\Exceptions\RateLimitException;
use Moderyo\Exceptions\ValidationException;
use Moderyo\Exceptions\QuotaExceededException;
use Moderyo\Exceptions\NetworkException;
use Moderyo\Exceptions\ModeryoException;

try {
    $result = $client->moderate($text);
} catch (AuthenticationException $e) {
    // Invalid API key (401)
} catch (RateLimitException $e) {
    sleep((int) $e->retryAfter);
} catch (ValidationException $e) {
    // Invalid input (400/422)
} catch (QuotaExceededException $e) {
    // Plan quota exceeded (402)
} catch (NetworkException $e) {
    // Connection/timeout after retries
} catch (ModeryoException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
```

Laravel Integration
-------------------

[](#laravel-integration)

Add MODERYO\_API\_KEY=your-key to .env. Service provider auto-discovers.

```
use Moderyo\Laravel\Facades\Moderyo;
$result = Moderyo::moderate('Check this text');
```

Running Tests
-------------

[](#running-tests)

```
composer install
vendor/bin/phpunit
```

Links
-----

[](#links)

- **Packagist:** [packagist.org/packages/moderyo/sdk](https://packagist.org/packages/moderyo/sdk)
- **Documentation:** [docs.moderyo.com/sdk/php](https://docs.moderyo.com/sdk/php)
- **Playground:** [playground-examples/php](https://github.com/Moderyo/playground-examples/tree/main/php)
- **Website:** [moderyo.com](https://moderyo.com)

License
-------

[](#license)

MIT - see [LICENSE](LICENSE).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance76

Regular maintenance activity

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

135d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35c82743354b49f9e64246a71419a9a8d4d9cd8d50bf5613301d23d23dc11ab5?d=identicon)[moderyo](/maintainers/moderyo)

---

Tags

aicomposercontent-moderationlaravelmoderationmoderyopackagistphpsafetysdkaicontent moderationmoderationsafetymoderyotrust-safety

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/moderyo-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/moderyo-sdk/health.svg)](https://phpackages.com/packages/moderyo-sdk)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M733](/packages/sylius-sylius)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M419](/packages/drupal-core-recommended)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k42](/packages/civicrm-civicrm-core)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k409.0k6](/packages/theodo-group-llphant)

PHPackages © 2026

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