Skip to content

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.

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: {},
},
}),
}
);

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.

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"]
}

Perspective API attributes are mapped to Sieve’s internal categories:

Perspective AttributeSieve CategoryDescription
TOXICITYtoxicityRude, disrespectful, or unreasonable language.
SEVERE_TOXICITYtoxicityVery hateful or aggressive language (higher threshold).
IDENTITY_ATTACKhate_speechAttacks based on identity attributes.
INSULTharassmentInsulting, inflammatory, or negative language toward a person.
PROFANITYtoxicitySwear words, curse words, and other obscene language.
THREATviolenceThreats of harm or violence against an individual or group.
Terminal window
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"])

While the request and response formats are compatible, there are a few differences:

  • Authentication — Sieve uses Authorization: Bearer or X-API-Key headers instead of a key query parameter.
  • Span scores — Sieve returns summaryScore only. Per-span scores are not currently supported.
  • Additional attributes — Perspective attributes like FLIRTATION and SEXUALLY_EXPLICIT are mapped to Sieve’s sexual category internally.
  • Rate limits — Follow your Sieve plan’s rate limits, not Perspective’s QPS limits.