Overview

Perspective API is a machine learning-powered tool designed to help developers and platforms assess the potential impact of online comments and content. Developed by Jigsaw, a unit within Google, the API analyzes text for various attributes of potential harm, including toxicity, insult, profanity, threat, and identity attack. Its primary function is to assist in content moderation efforts, enabling platforms to identify and manage problematic user-generated content at scale. This capability is particularly relevant for social media platforms, forums, news sites, and any online community where user interactions are prevalent and require oversight to maintain a positive environment.

The API operates by sending text to its endpoints, which then return a score for each requested attribute, indicating the likelihood that the text exhibits that characteristic. For instance, a high 'toxicity' score suggests that a comment is perceived as rude, disrespectful, or unreasonable. Developers can configure the API to detect specific attributes relevant to their community guidelines. This granular scoring allows for nuanced moderation strategies, from flagging content for human review to automated filtering or even providing real-time feedback to users as they type, encouraging more constructive communication. For example, a gaming forum might use Perspective API to automatically filter out highly toxic comments in public chat channels, while a news site might use it to flag comments that are likely to be spam or off-topic for moderator review.

Integrating Perspective API can contribute to fostering healthier online conversations by reducing the prevalence of harmful content. It is suitable for organizations aiming to scale their content moderation without relying solely on manual review, which can be resource-intensive and inconsistent. The API's flexibility, with support for multiple programming languages through official SDKs, facilitates its adoption across diverse technical stacks. Its focus on specific attributes of harmful speech provides a structured approach to content analysis, moving beyond simple keyword blocking to context-aware evaluation. The API's developer documentation and sample code offer practical guidance for implementation, making it accessible for teams to integrate its capabilities into existing moderation workflows.

Key features

  • Toxicity detection: Identifies comments perceived as rude, disrespectful, or unreasonable, helping to maintain polite discussion environments.
  • Attribute scoring: Provides granular scores for various negative attributes such as insult, profanity, threat, sexual explicit content, and identity attack, allowing for detailed content analysis.
  • Multi-language support: Capable of analyzing content in several languages, making it suitable for global platforms.
  • Real-time analysis: Offers near real-time processing of text submissions, enabling dynamic content moderation and user feedback systems.
  • Customizable thresholds: Developers can set specific score thresholds for each attribute to trigger actions, aligning with their platform's unique content policies.
  • Comprehensive documentation: Provides extensive developer documentation, including sample code and integration guides, to streamline implementation.
  • SDK availability: Supports multiple programming languages with official SDKs (Python, Node.js, Java, PHP, Go, Ruby, C#) for easier integration.

Pricing

Perspective API offers a tiered pricing structure, including a free tier for initial usage and testing. The pricing model is based on the number of requests made to the API.

Tier Requests per Month Cost per 1,000 Requests Notes
Free Up to 10,000 $0.00 Ideal for small projects and evaluation
Standard Tier 1 10,001 - 50,000 $0.75
Standard Tier 2 50,001 - 1,000,000 $0.60
High Volume Over 1,000,000 Contact Sales Custom pricing for enterprise-level usage

Pricing as of May 2026. For the most current pricing details, refer to the official Perspective API homepage.

Common integrations

Perspective API is designed for integration into various applications and platforms requiring content moderation capabilities. While direct integrations with specific third-party tools are not always explicitly listed as 'plugins,' its API-first approach allows for broad compatibility. Common integration scenarios include:

  • Web forums and comment sections: Integrating into platforms like Discourse or custom-built forums to analyze user comments before publication or for real-time flagging.
  • Social media platforms: Used by social networks to moderate user-generated content, detect harmful posts, and enforce community guidelines.
  • Gaming platforms: Applied in in-game chat systems to filter toxic language and promote a positive gaming experience.
  • Customer support systems: Analyzing incoming customer messages or chat transcripts to identify abusive language or high-priority emotional distress indicators.
  • Educational platforms: Moderating discussion boards and student interactions to ensure a safe and respectful learning environment.
  • Content management systems (CMS): Integrating into CMS workflows to pre-screen user submissions, such as blog comments or user reviews.

Alternatives

  • OpenAI Moderation API: Offers a general-purpose moderation endpoint for identifying categories of harmful content, including hate speech and sexual content.
  • Amazon Rekognition: Provides image and video analysis, including content moderation features for detecting inappropriate content visually.
  • Google Cloud Natural Language API: Offers sentiment analysis, entity recognition, and content classification, which can be adapted for moderation tasks, though not specifically focused on toxicity.
  • Azure AI Content Moderator: A service that helps detect potentially offensive, risky, or otherwise undesirable material across text, image, and video.

Getting started

To begin using Perspective API, you typically obtain an API key and then use one of the available client libraries (SDKs) to send text for analysis. Here's a basic example using Python to analyze a comment for toxicity:

from googleapiclient import discovery
import json

API_KEY = "YOUR_API_KEY"

client = discovery.build(
    "commentanalyzer",
    "v1alpha1",
    developerKey=API_KEY,
    discoveryServiceUrl="https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1",
    static_fields=False,
)

analyze_request = {
    'comment': {'text': 'You are an idiot and your ideas are terrible.'},
    'requestedAttributes': {'TOXICITY': {}}
}

response = client.comments().analyze(body=analyze_request).execute()
print(json.dumps(response, indent=2))

This Python code snippet demonstrates how to initialize the Perspective API client and send a request to analyze a comment for 'TOXICITY'. The response will include a score indicating the likelihood of the comment being toxic. For Node.js, a similar process involves installing the Google APIs client library and structuring the request body. Detailed setup instructions and more examples across supported languages are available in the Perspective API sample code documentation.