Profanity filtering users can't bypass.
The Google client builds itself from a discovery document. Ours names api.unprofane.com as its root, so the client keeps working.
Tested with google-api-python-client 2.201.0, on every run of the snippet checks. How
client = discovery.build("commentanalyzer","v1alpha1",developerKey=os.environ["UNPROFANE_KEY"], # up_test_YOUR_KEY on staging, up_live_YOUR_KEY in productionRemove: discoveryServiceUrl="https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1",Add: discoveryServiceUrl="https://api.unprofane.com/$discovery/rest?version=v1alpha1",static_discovery=False,)response = client.comments().analyze(body={"comment": {"text": "you are a clown"},"requestedAttributes": {"TOXICITY": {}},"languages": ["en"],"doNotStore": True,}).execute()1 line changes. Give discovery.build a discoveryServiceUrl on the Unprofane host and keep every call the same.
Tested with google-api-python-client 2.201.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.
Pass the Unprofane discovery URL and read the key from the environment, so staging (the test key) and production (the live key) differ only in the value. Everything after the build call is unchanged.
import os
from googleapiclient import discovery
client = discovery.build(
"commentanalyzer",
"v1alpha1",
developerKey=os.environ["UNPROFANE_KEY"], # up_test_YOUR_KEY on staging, up_live_YOUR_KEY in production
discoveryServiceUrl="https://api.unprofane.com/$discovery/rest?version=v1alpha1",
static_discovery=False,
)
response = client.comments().analyze(body={
"comment": {"text": "you are a clown"},
"requestedAttributes": {"TOXICITY": {}},
"languages": ["en"],
"doNotStore": True,
}).execute()
print(response["attributeScores"]["TOXICITY"]["summaryScore"]["value"])Run your own tests against staging with the test key. A refusal arrives as an HttpError with Google’s status and words, so the error handling you wrote for Perspective keeps working.
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.
Put Google’s discovery URL and your Google key back. This works until Google’s service ends on December 31, 2026.
discoveryServiceUrl="https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1"Tested with google-api-python-client 2.201.0 on every run of the snippet checks: this guide’s code as printed with a test key and a live key, then three 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.