apyhub
Back
ARTIFICIAL INTELLIGENCE · SECURITY & PRIVACY

Detect Text Toxicity API

What it does

The Detect Text Toxicity API is a toxicity detection API that checks whether a comment or message is toxic or harmful. Send a piece of text and get back a clear verdict, toxic or non-toxic, with a score showing how confident the model is.

It is one POST endpoint with a single text field, and the answer comes back in the same request. The response includes toxic as true or false, a label such as non-toxic, a score between 0 and 1, and the text that was checked. Use toxic for a simple allow or block decision, or apply your own threshold to score: auto-hide the most confident cases and send borderline ones to a human moderator. Input is limited to 512 characters, which covers comments, chat messages, reviews, bios and support tickets.

Unlike a word list, a toxicity model reads the whole message, so it can flag insults, harassment and hostile comments that contain no swear words at all. Common uses include moderating comment sections and forums, screening chat in communities and games, flagging abusive support tickets, reviewing profile bios at sign-up, and checking AI chatbot replies before they reach users.

Google's Perspective API, the most widely used free toxicity API, is shutting down on 31 December 2026 with no migration path. If you are moving off it, note that this API returns one toxicity verdict and score rather than separate scores for insults, threats and identity attacks, which keeps the integration simple.

To catch explicit swear words with an exact list of matches, pair it with the CheckText Profanity API. For broader content moderation, use the AI Text Moderation API, and to measure whether feedback is positive or negative instead of harmful, use the Analyze Multiple Text Sentiment API.

You can try it right here in the playground. Start for free with 5 API calls a day, no card required, and check your own text before you commit.

The API is also available through ApyHub MCP, so AI agents can check text for toxicity directly before they publish or reply.

POST
Detect whether text is toxic or harmful
https://api.eu.apyhub.com/dosvak/detect-toxicity

QUICKSTART

GUIDE

Quickstart

Send a piece of text to check whether it is toxic.

curl -X POST "https://api.eu.apyhub.com/dosvak/detect-toxicity" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text":"This is a sample sentence to analyze."}'

What you'll get back

Returns a JSON object with text as a string, label as a string, score as a number, and toxic as a boolean.

{
  "text": "This is a sample sentence to analyze.",
  "label": "non-toxic",
  "score": 0.98,
  "toxic": false
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Input text. Maximum length: 512 characters.

About this endpoint

What it does

Detects whether the submitted text is toxic or harmful and returns a JSON object with the analyzed text, a label, a score, and a toxic boolean.

Request Body

ParameterTypeMandatoryDescription
textStringYesInput text to analyze. Maximum length: 512 characters.

Response

Returns a JSON object with four top-level fields: text as a string, label as a string, score as a number, and toxic as a boolean. Use toxic to determine whether the input was classified as toxic or harmful.

ParameterTypeMandatoryDescription
textStringNoThe text that was analyzed.
labelStringNoThe classification label returned by the service.
scoreNumberNoThe confidence or score returned by the service.
toxicBooleanNoWhether the text is classified as toxic or harmful.

Body

Name
Type
Description
bodyREQUIRED
object
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.