# Text Moderation & AI Text Detector: Toxicity, Hate, Spam (`pomlabs/text-moderation-ai-detector`) Actor

Moderate comments, reviews and chat messages in any language: 0 to 1 scores for toxic, hate, harassment, sexual, violence, self-harm, spam and profanity, a flagged verdict, and an AI-written-text score with a verdict, in one call. No API key.

- **URL**: https://apify.com/pomlabs/text-moderation-ai-detector.md
- **Developed by:** [Trawlyard](https://apify.com/pomlabs) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 text analyzed

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Text Moderation & AI Text Detector

Moderate comments, reviews, chat messages and posts in **any language** (English, Portuguese, Spanish and more). For each text you get a **0 to 1 score** for eight categories, a **flagged** verdict, and an **AI-written text score** with a verdict, all in one call. Up to 100 texts per run, no API key.

### What you get for each text

| Field | What it is |
|---|---|
| `flagged` | `true` when any category you asked for reaches the threshold (default 0.3) |
| `flaggedLabels` | The categories that reached it, highest first |
| `threshold` | The threshold used for this text |
| `scores` | `toxic`, `hate`, `harassment`, `sexual`, `violence`, `self_harm`, `spam`, `profanity`, each 0 to 1 |
| `aiScore` | 0 to 1: how likely the text was written by an AI model rather than typed by a person |
| `aiGenerated` | `true` when `aiScore` is 0.5 or more |
| `aiVerdict` | `likely_ai` (0.7 or more), `likely_human` (0.3 or less), `uncertain`, or `too_short` (under 25 characters) |
| `truncated`, `chars` | Texts longer than 10,000 characters are analyzed up to that length; `truncated` says so |
| `id` | Your own id, when you send `{"text": "...", "id": "..."}` instead of a plain string |
| `status`, `error` | `ok`, or why the text was not analyzed (`empty_text`, `run_time_limit`, `classifier_unavailable`) |

You are charged only for texts that come back with `status: ok`.

### Input

```json
{
  "texts": [
    "You are a complete idiot and nobody wants you here.",
    {"text": "Thanks for the quick reply, the package arrived today!", "id": "review-1042"},
    "Esse político é um lixo, vagabundo e ladrão."
  ],
  "categories": ["toxic", "hate", "harassment", "sexual", "violence", "self_harm", "spam", "profanity"],
  "threshold": "0.3",
  "detectAi": true
}
```

- `texts`: up to 100, strings or `{text, id}` objects. Empty texts are returned as `empty_text` and not charged.
- `categories`: which categories to score. Empty means all eight.
- `threshold`: 0.05 to 0.95. Lower catches more and flags more clean texts; 0.3 is the default.
- `detectAi`: turn off to skip the AI-written score.

### Example output

```json
{
  "index": 0,
  "text": "You are a worthless piece of garbage and everyone at this company hates you.",
  "status": "ok",
  "flagged": true,
  "flaggedLabels": [
    "toxic",
    "hate",
    "harassment",
    "profanity"
  ],
  "scores": {
    "toxic": 1.0,
    "hate": 1.0,
    "harassment": 1.0,
    "sexual": 0.0,
    "violence": 0.0,
    "self_harm": 0.0,
    "spam": 0.0,
    "profanity": 1.0
  },
  "threshold": 0.3,
  "truncated": false,
  "chars": 76,
  "aiGenerated": false,
  "aiScore": 0.0,
  "aiVerdict": "likely_human"
}
```

### Use it from code, from the API or from an AI agent

- **Run it** from the Apify console, the API or any Apify client, like any Actor.
- **Server mode**: send `POST /moderate` with the same JSON body for an answer in seconds, without an Actor start. Use POST (not a query string) when your texts contain commas.
- **MCP**: the tool `moderate_text` is available at `/mcp` for Claude, Cursor and other agents.

### Use cases

- **Comments and reviews**: hold back insults, hate, threats, sexual content and spam before they go live.
- **Chat and community moderation**: score every message, flag the ones over your own threshold, and send only those to a human.
- **Scraped text**: chain it after a social, review or forum scraper to clean the data you collected.
- **Education and publishing**: check whether a submission looks AI-written, as one signal among others.
- **Profanity filters that understand context**: words that only contain a swear word inside them, or a news report about violence, are scored by meaning and not by a word list.

### Limits and honest notes

- Scores are model estimates, not a legal judgement. Keep a person in the loop for bans, appeals and anything with legal weight.
- **The AI-written score is a score, not proof.** Detectors of AI text make mistakes in both directions, and text that was edited or paraphrased after an AI wrote it is much harder to catch. Do not use it alone to accuse anyone. Texts under 25 characters get no AI score.
- Quality varies with the language and the topic. Sarcasm, quotes that condemn what they quote, and promotions that look like ads can score higher than you expect: adjust `threshold` and `categories` to your own data.
- Each text is read up to 10,000 characters. Up to 100 texts per run; split larger lists.
- This Actor does not store your texts. Each text is sent to the classification service and dropped; only the scores are saved, in your own dataset.

### More Trawlyard Actors

Other Actors from Trawlyard for the same kind of job:

- [Image Moderation & Tagger (NSFW detector)](https://apify.com/pomlabs/image-moderation-tagger)
- [Instagram Transcript Scraper](https://apify.com/pomlabs/social-video-transcript)
- [Video Downloader](https://apify.com/pomlabs/video-downloader)

### Support, feedback and requests

Questions, bug reports, complaints, feature requests, or an idea for a new tool? Email us at **support@trawlyard.com**, in any language. We read our inbox every day and answer every message. Suggestions and feedback of every kind are welcome: tell us what you need and we will look into it.

# Actor input Schema

## `texts` (type: `array`):

The texts to moderate, up to 100 per run, any language (Portuguese included). Each text is read up to 10,000 characters. An item can also be an object {"text": "...", "id": "your-id"}; the id comes back in the result.

## `categories` (type: `array`):

Which categories to score. Any of: toxic, hate, harassment, sexual, violence, self_harm, spam, profanity. Empty means all eight.

## `threshold` (type: `string`):

Score from 0.05 to 0.95 at which a category flags the text. Lower catches more and flags more clean texts. Default 0.3.

## `detectAi` (type: `boolean`):

Also return aiScore (0 to 1), aiGenerated and aiVerdict for each text of 25 characters or more. It is a score, not proof.

## Actor input object example

```json
{
  "texts": [
    "You are a complete idiot and nobody wants you here.",
    "Thanks for the quick reply, the package arrived today!",
    "Esse político é um lixo, vagabundo e ladrão."
  ],
  "categories": [
    "toxic",
    "hate",
    "harassment",
    "sexual",
    "violence",
    "self_harm",
    "spam",
    "profanity"
  ],
  "threshold": "0.3",
  "detectAi": true
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "texts": [
        "You are a complete idiot and nobody wants you here.",
        "Thanks for the quick reply, the package arrived today!",
        "Esse político é um lixo, vagabundo e ladrão."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("pomlabs/text-moderation-ai-detector").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "texts": [
        "You are a complete idiot and nobody wants you here.",
        "Thanks for the quick reply, the package arrived today!",
        "Esse político é um lixo, vagabundo e ladrão.",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("pomlabs/text-moderation-ai-detector").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "texts": [
    "You are a complete idiot and nobody wants you here.",
    "Thanks for the quick reply, the package arrived today!",
    "Esse político é um lixo, vagabundo e ladrão."
  ]
}' |
apify call pomlabs/text-moderation-ai-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pomlabs/text-moderation-ai-detector"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/sfT0213zLgDHKkyme/builds/03DXSNc63cg1SqFtn/openapi.json
