# Perspective API Alternative: Toxicity Score API (`ferrolark/toxicity-score-api`) Actor

Google Perspective API alternative for comments, reviews and chat, before the 31 Dec 2026 shutdown. Seven scores (0-1) in a compatible format: toxicity, severe toxicity, insult, threat, profanity, identity attack, sexually explicit. Multilingual (EN, ES, FR, IT, PT, RU, TR). $0.50 per 1,000 texts.

- **URL**: https://apify.com/ferrolark/toxicity-score-api.md
- **Developed by:** [Ferrolark](https://apify.com/ferrolark) (community)
- **Categories:** AI, Developer tools, Social media
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.50 / 1,000 text scoreds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-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

## Toxicity Score API: Perspective API Replacement (Multilingual)

**Google's Perspective API shuts down on 31 December 2026.** This Actor gives you the same kind of answer — a probability from 0 to 1 for each toxicity attribute — so your moderation queue, comment filter or research pipeline keeps working with a one-line change.

- **The 7 Perspective attributes:** `toxicity`, `severe_toxicity`, `insult`, `threat`, `profanity`, `identity_attack` and `sexual_explicit` for every text.
- **Compatible format:** send Perspective `AnalyzeComment` request bodies as they are (`{"comment": {"text": ...}, "languages": [...], "requestedAttributes": {...}}`) and turn on `perspectiveFormat` to get `attributeScores.TOXICITY.summaryScore.value` back.
- **A decision, not just numbers:** `flagged`, `flaggedAttributes` and `topLabel` from thresholds you set (globally or per attribute).
- **Multilingual:** trained on English, Spanish, French, Italian, Portuguese, Russian and Turkish; other languages work zero-shot.
- **No API key, no data sent to a third party:** an open model (Detoxify multilingual, built on XLM-RoBERTa and trained on the Jigsaw datasets that Perspective itself came from) runs inside the Actor.
- **Bulk friendly:** up to 20,000 texts per run, from a list or straight from an Apify dataset (for example a comments or reviews scraper).

### Example

```json
{
  "texts": [
    {"id": "en-2", "text": "You are a complete idiot and nobody wants you here."},
    {"id": "en-3", "text": "If I ever see you again I will kill you."},
    {"id": "es-2", "text": "Eres un imbécil, cállate ya."}
  ],
  "threshold": "0.7"
}
```

Output (one row per text):

```json
{"id": "en-2", "text": "You are a complete idiot and nobody wants you here.",
 "toxicity": 0.9966, "severe_toxicity": 0.0016, "insult": 0.9858, "threat": 0.0015, "profanity": 0.055, "identity_attack": 0.0011, "sexual_explicit": 0.0025,
 "flagged": true, "flaggedAttributes": ["toxicity", "insult"], "topLabel": "insult", "topScore": 0.9858,
 "language": "auto", "languageSupport": "auto", "tokens": 14, "truncated": false}
```

| Text | toxicity | insult | threat | topLabel |
|---|---|---|---|---|
| Thanks for the quick reply, this fixed my problem! | 0.00 | 0.00 | 0.00 | none |
| You are a complete idiot and nobody wants you here. | 1.00 | 0.99 | 0.00 | insult |
| If I ever see you again I will kill you. | 0.99 | 0.08 | 0.94 | threat |
| Muchas gracias por la ayuda, me ha servido mucho. | 0.00 | 0.03 | 0.00 | none |
| Eres un imbécil, cállate ya. | 0.99 | 0.33 | 0.00 | toxicity |
| Como te vuelva a ver te mato. | 0.97 | 0.02 | 0.75 | threat |

With **no input at all** the Actor scores these six sample texts, so you can see the output before sending your own.

### Migrating from Perspective

| Perspective | This Actor |
|---|---|
| `POST comments:analyze` with `{"comment": {"text": ...}}` | Put the same objects in `texts` (one or thousands per call). |
| `attributeScores.TOXICITY.summaryScore.value` | Same path with `perspectiveFormat: true`, or flat `toxicity`. |
| `SEVERE_TOXICITY`, `INSULT`, `THREAT`, `PROFANITY`, `IDENTITY_ATTACK`, `SEXUALLY_EXPLICIT` | All returned; `requestedAttributes` limits the Perspective-format block. |
| `languages` | Optional and informational; the model is multilingual and needs no hint. |
| API key + QPS quota | Your Apify token; batch up to 20,000 texts per run. |

Scores come from a different model, so they are **similar in meaning but not identical** to Perspective's. Re-check your thresholds on a sample of your own data (start at 0.7, as with Perspective).

### Price

- **$0.0005 per text scored** (1,000 texts = $0.50; 100,000 = $50).
- Not charged: empty texts, texts over 20,480 characters, and runs that fail before scoring.
- Set *Max total charge* on the run to cap your spend; the Actor stops cleanly at that limit.

### Input

| Field | Default | What it does |
|---|---|---|
| `texts` | 6 samples | Strings, `{"id", "text"}` objects or Perspective requests. Up to 20,000 per run (1,000 on the Apify free plan). |
| `datasetId` | none | Score the items of an Apify dataset. |
| `textField` / `idField` | auto | Which fields hold the text and the id (defaults: `text`, `comment`, `content`, `body`, `message`, `review`, `title`; `id`). |
| `language` | `auto` | Informational; per-item `languages` also accepted. |
| `threshold` | `0.7` | Score at which an attribute is flagged. |
| `thresholds` | none | Per-attribute overrides, e.g. `{"threat": 0.5}`. |
| `perspectiveFormat` | `false` | Adds `attributeScores` and `languages` like Perspective's response. |
| `requestedAttributes` | all | Limits the Perspective-format block. |
| `includeText` | `true` | Turn off to return only ids and scores. |

The run's key-value store also gets an `OUTPUT` summary: texts scored, flags per attribute, top labels and timing.

### Call it from code, n8n or an AI agent

```bash
curl -X POST "https://api.apify.com/v2/acts/ferrolark~toxicity-score-api/run-sync-get-dataset-items?maxTotalChargeUsd=0.05" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"texts": ["You are a moron.", "Gracias por todo"], "perspectiveFormat": true}'
```

An importable n8n workflow (trigger → Actor → IF `flagged`) is in `examples/n8n-workflow.json`. In Make or Zapier, use the Apify "Run Actor" module and branch on `flagged` or `topLabel`.

### Good to know

- Speed: about 80 ms per short comment at the default 2 GB memory (1,000 comments in roughly 1.5 minutes); more memory adds CPU threads.
- Each text is scored on its first 512 tokens (roughly 1,500–2,000 characters); longer texts are marked `truncated: true`.
- Sub-attribute scores (insult, threat, profanity) are best calibrated in English. In other languages `toxicity` is the most reliable signal, which is why `topLabel` falls back to `toxicity` when no sub-attribute passes its threshold.
- Implicit threats and sarcasm without offensive words can score low, as with any classifier of this kind. Use it to prioritise human review, not as the only judge.
- Your texts are processed only inside the run and stored only in your own run's dataset.

### FAQ

**Do I need a Google, OpenAI or other API key?**

No. The model is inside the Actor and its cost is included in the per-text price.

**Is it really free of external calls?**

Yes. Texts never leave the Apify run.

**Can I use it commercially?**

Yes. The model (Detoxify, by Unitary) is released under the Apache 2.0 licence.

### More Ferrolark tools

- [Support Ticket Triage](https://apify.com/ferrolark/ticket-triage)
- [Criteria Checker](https://apify.com/ferrolark/criteria-checker)
- [RSS Delta](https://apify.com/ferrolark/rss-delta)

***

*Built by Ferrolark. Not affiliated with Google, Jigsaw or Unitary. "Perspective API" is mentioned only to describe compatibility.*

# Actor input Schema

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

Up to 20,000 per run (1,000 on the Apify free plan), max 20,480 characters each. Plain strings, {"id", "text"} objects, or Perspective AnalyzeComment requests ({"comment": {"text": "..."}, "languages": \["en"], "requestedAttributes": {"TOXICITY": {}}}). If empty and no dataset is given, 6 sample texts (English and Spanish) are scored.

## `datasetId` (type: `string`):

Score the items of an Apify dataset (for example the output of a comments or reviews scraper). Added after any texts above.

## `textField` (type: `string`):

Field holding the text in dataset items or objects. If empty, the first of text, comment, content, body, message, review, title is used.

## `idField` (type: `string`):

Field copied to "id" in the output (default: id, else text-1, text-2...).

## `language` (type: `string`):

Informational: the model is multilingual and needs no language hint. Trained on en, es, fr, it, pt, ru, tr; other languages work zero-shot with lower accuracy. Per-item "languages" (Perspective style) override it.

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

Score (0-1) at which an attribute counts as flagged. 0.7 is the usual Perspective starting point; use 0.5 for more recall, 0.85-0.9 for fewer false positives.

## `thresholds` (type: `object`):

Optional overrides, e.g. {"threat": 0.5, "profanity": 0.9}. Perspective names (THREAT, PROFANITY...) also work.

## `perspectiveFormat` (type: `boolean`):

Also return attributeScores.{TOXICITY,...}.summaryScore.value and languages, like Perspective's AnalyzeComment response, so existing parsing code keeps working.

## `requestedAttributes` (type: `array`):

Limit attributeScores to these (e.g. TOXICITY, INSULT). Flat scores are always returned.

## `includeText` (type: `boolean`):

Turn off to keep only ids and scores (texts over 1,000 characters are shortened anyway).

## Actor input object example

```json
{
  "texts": [
    {
      "id": "en-1",
      "text": "Thanks for the quick reply, this fixed my problem!"
    },
    {
      "id": "en-2",
      "text": "You are a complete idiot and nobody wants you here."
    },
    {
      "id": "en-3",
      "text": "If I ever see you again I will kill you."
    },
    {
      "id": "es-1",
      "text": "Muchas gracias por la ayuda, me ha servido mucho."
    },
    {
      "id": "es-2",
      "text": "Eres un imbécil, cállate ya."
    },
    {
      "id": "es-3",
      "text": "Como te vuelva a ver te mato."
    }
  ],
  "language": "auto",
  "threshold": "0.7",
  "perspectiveFormat": false,
  "includeText": true
}
```

# Actor output Schema

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

No description

## `files` (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": [
        {
            "id": "en-1",
            "text": "Thanks for the quick reply, this fixed my problem!"
        },
        {
            "id": "en-2",
            "text": "You are a complete idiot and nobody wants you here."
        },
        {
            "id": "en-3",
            "text": "If I ever see you again I will kill you."
        },
        {
            "id": "es-1",
            "text": "Muchas gracias por la ayuda, me ha servido mucho."
        },
        {
            "id": "es-2",
            "text": "Eres un imbécil, cállate ya."
        },
        {
            "id": "es-3",
            "text": "Como te vuelva a ver te mato."
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ferrolark/toxicity-score-api").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": [
        {
            "id": "en-1",
            "text": "Thanks for the quick reply, this fixed my problem!",
        },
        {
            "id": "en-2",
            "text": "You are a complete idiot and nobody wants you here.",
        },
        {
            "id": "en-3",
            "text": "If I ever see you again I will kill you.",
        },
        {
            "id": "es-1",
            "text": "Muchas gracias por la ayuda, me ha servido mucho.",
        },
        {
            "id": "es-2",
            "text": "Eres un imbécil, cállate ya.",
        },
        {
            "id": "es-3",
            "text": "Como te vuelva a ver te mato.",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ferrolark/toxicity-score-api").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": [
    {
      "id": "en-1",
      "text": "Thanks for the quick reply, this fixed my problem!"
    },
    {
      "id": "en-2",
      "text": "You are a complete idiot and nobody wants you here."
    },
    {
      "id": "en-3",
      "text": "If I ever see you again I will kill you."
    },
    {
      "id": "es-1",
      "text": "Muchas gracias por la ayuda, me ha servido mucho."
    },
    {
      "id": "es-2",
      "text": "Eres un imbécil, cállate ya."
    },
    {
      "id": "es-3",
      "text": "Como te vuelva a ver te mato."
    }
  ]
}' |
apify call ferrolark/toxicity-score-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ferrolark/toxicity-score-api"
        }
    }
}
```

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/tjKkbg0GrGbh0jgba/builds/Iybo9OGt3WOPC0EXM/openapi.json
