Perspective API Compatibility
The Perspective API compatibility endpoint accepts the same request format and returns the same response format as the Google Perspective API. With Google sunsetting Perspective on December 31, 2026, this endpoint lets you migrate with a single URL change.
Migration Guide
Section titled “Migration Guide”Migrating from Google Perspective to Sieve takes one change — swap the URL and auth:
import requests
response = requests.post( "https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze", params={"key": "YOUR_GOOGLE_API_KEY"}, json={ "comment": {"text": "You are an idiot"}, "requestedAttributes": { "TOXICITY": {}, "IDENTITY_ATTACK": {}, "INSULT": {}, "THREAT": {} } },)import requests
response = requests.post( "https://api.getsieve.dev/v1/perspective/analyze", headers={"Authorization": "Bearer mod_live_abc123..."}, json={ "comment": {"text": "You are an idiot"}, "requestedAttributes": { "TOXICITY": {}, "IDENTITY_ATTACK": {}, "INSULT": {}, "THREAT": {} } },)const response = await fetch( "https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze?key=YOUR_GOOGLE_API_KEY", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ comment: { text: "You are an idiot" }, requestedAttributes: { TOXICITY: {}, IDENTITY_ATTACK: {}, INSULT: {}, THREAT: {}, }, }), });const response = await fetch( "https://api.getsieve.dev/v1/perspective/analyze", { method: "POST", headers: { "Authorization": "Bearer mod_live_abc123...", "Content-Type": "application/json", }, body: JSON.stringify({ comment: { text: "You are an idiot" }, requestedAttributes: { TOXICITY: {}, IDENTITY_ATTACK: {}, INSULT: {}, THREAT: {}, }, }), });Request
Section titled “Request”The request body follows the Perspective API format exactly:
The comment to analyze.
The text content to analyze.
A map of Perspective attribute names to empty objects. Each key requests scoring for that attribute.
Supported attributes: TOXICITY, SEVERE_TOXICITY, IDENTITY_ATTACK, INSULT, PROFANITY, THREAT.
ISO 631-1 language codes. Optional. Defaults to auto-detection.
Response
Section titled “Response”The response matches the Perspective API format:
{ "attributeScores": { "TOXICITY": { "summaryScore": { "value": 0.91, "type": "PROBABILITY" } }, "IDENTITY_ATTACK": { "summaryScore": { "value": 0.12, "type": "PROBABILITY" } }, "INSULT": { "summaryScore": { "value": 0.87, "type": "PROBABILITY" } }, "THREAT": { "summaryScore": { "value": 0.08, "type": "PROBABILITY" } } }, "languages": ["en"]}Attribute Mapping
Section titled “Attribute Mapping”Perspective API attributes are mapped to Sieve’s internal categories:
| Perspective Attribute | Sieve Category | Description |
|---|---|---|
TOXICITY | toxicity | Rude, disrespectful, or unreasonable language. |
SEVERE_TOXICITY | toxicity | Very hateful or aggressive language (higher threshold). |
IDENTITY_ATTACK | hate_speech | Attacks based on identity attributes. |
INSULT | harassment | Insulting, inflammatory, or negative language toward a person. |
PROFANITY | toxicity | Swear words, curse words, and other obscene language. |
THREAT | violence | Threats of harm or violence against an individual or group. |
Full Example
Section titled “Full Example”curl -X POST https://api.getsieve.dev/v1/perspective/analyze \ -H "Authorization: Bearer mod_live_abc123..." \ -H "Content-Type: application/json" \ -d '{ "comment": { "text": "You are an idiot and nobody likes you" }, "requestedAttributes": { "TOXICITY": {}, "INSULT": {}, "IDENTITY_ATTACK": {}, "THREAT": {} } }'const response = await fetch("https://api.getsieve.dev/v1/perspective/analyze", { method: "POST", headers: { "Authorization": "Bearer mod_live_abc123...", "Content-Type": "application/json", }, body: JSON.stringify({ comment: { text: "You are an idiot and nobody likes you" }, requestedAttributes: { TOXICITY: {}, INSULT: {}, IDENTITY_ATTACK: {}, THREAT: {}, }, }),});
const result = await response.json();console.log(result.attributeScores.TOXICITY.summaryScore.value);import requests
response = requests.post( "https://api.getsieve.dev/v1/perspective/analyze", headers={ "Authorization": "Bearer mod_live_abc123...", "Content-Type": "application/json", }, json={ "comment": {"text": "You are an idiot and nobody likes you"}, "requestedAttributes": { "TOXICITY": {}, "INSULT": {}, "IDENTITY_ATTACK": {}, "THREAT": {}, }, },)
result = response.json()print(result["attributeScores"]["TOXICITY"]["summaryScore"]["value"])Differences from Google Perspective
Section titled “Differences from Google Perspective”While the request and response formats are compatible, there are a few differences:
- Authentication — Sieve uses
Authorization: BearerorX-API-Keyheaders instead of akeyquery parameter. - Span scores — Sieve returns
summaryScoreonly. Per-span scores are not currently supported. - Additional attributes — Perspective attributes like
FLIRTATIONandSEXUALLY_EXPLICITare mapped to Sieve’ssexualcategory internally. - Rate limits — Follow your Sieve plan’s rate limits, not Perspective’s QPS limits.