Profanity filtering users can't bypass.
googleapis builds a client from a discovery document. Ours names api.unprofane.com as its root, so the same methods call Unprofane.
Tested with googleapis 185.0.0, on every run of the snippet checks. How
const client = await google.discoverAPI(Remove: 'https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1',Add: 'https://api.unprofane.com/$discovery/rest?version=v1alpha1',);const res = await client.comments.analyze({key: process.env.UNPROFANE_KEY, // up_test_YOUR_KEY on staging, up_live_YOUR_KEY in productionresource: {comment: { text: 'you are a clown' },requestedAttributes: { TOXICITY: {} },languages: ['en'],doNotStore: true,},});1 line changes. Build the client with google.discoverAPI from the Unprofane discovery URL and keep the calls.
Tested with googleapis 185.0.0, on every run of the snippet checks.
Sign in and make two keys on the keys page of the dashboard: a test key (up_test_…) for staging and a live key (up_live_…) for production. A test key is free and answers 100 checks a month across the account; a live key needs a plan. Keep your Google key: it is your way back until Google’s service ends on December 31, 2026.
google.discoverAPI fetches our discovery document and builds comments.analyze and comments.suggestscore from it, aimed at the root the document names. Read the key from the environment, so staging and production differ only in the value. Every call after it is unchanged.
import { google } from 'googleapis';
const client = await google.discoverAPI(
'https://api.unprofane.com/$discovery/rest?version=v1alpha1',
);
const res = await client.comments.analyze({
key: process.env.UNPROFANE_KEY, // up_test_YOUR_KEY on staging, up_live_YOUR_KEY in production
resource: {
comment: { text: 'you are a clown' },
requestedAttributes: { TOXICITY: {} },
languages: ['en'],
doNotStore: true,
},
});
console.log(res.data.attributeScores.TOXICITY.summaryScore.value);Run your own tests against staging with the test key. A refusal rejects with Google’s status as error.code and Google’s words in error.message.
Do not carry the old number over: the scores come from a different engine, so 0.8 there is not 0.8 here. The replay tool takes a CSV of recent texts with the scores Perspective gave them and shows, for each old threshold, the threshold here that flags the same share, and how often the two flags agree. A queue of the same size is not proof of the same accuracy: two thresholds can flag the same number of comments and disagree on which ones, and agreement with Perspective repeats its mistakes. Before production, run a sample your moderators have already decided (approved and removed) through staging, and for each candidate threshold count the removed items it catches and the approved items it flags. Read the disagreements, then choose.
Discover from Google’s URL again and put your Google key back. This works until Google’s service ends on December 31, 2026.
const client = await google.discoverAPI(
'https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1',
);Tested with googleapis 185.0.0 on every run of the snippet checks: this guide’s code as printed with a test key and a live key, then two refusals, a bad key and a suggestscore, against a local Unprofane API. It passed against the real model on October 13, 2026, and its rollback against Google’s own API on October 13, 2026.