Unprofane

Move Discourse off the Perspective API

The plugin hardcodes GOOGLE_API_DOMAIN. The move is a one-line fork, a container rebuild and the key setting.

Tested with Discourse 2026.10.0-latest itself, run on October 13, 2026. How

Discourse

What changes

lib/discourse_perspective.rb, in your fork
Remove: GOOGLE_API_DOMAIN = "https://commentanalyzer.googleapis.com"Add: GOOGLE_API_DOMAIN = "https://api.unprofane.com"
Site settings
perspective_enabled:        trueRemove: perspective_google_api_key: YOUR_GOOGLE_KEYAdd: perspective_google_api_key: up_test_YOUR_KEYperspective_toxicity_model: standard

2 lines change. The discourse-perspective-api plugin hardcodes Google’s host and has no endpoint setting. Fork it, change one line, rebuild, and put an Unprofane key in perspective_google_api_key. A Discourse you cannot add plugins to cannot run the fork.

Tested with Discourse 2026.10.0-latest itself, run on October 13, 2026.

  • Unchanged
  • The path
  • The request body
  • The response
  • The errors
  • The ?key= parameter

1. Check that you can change plugin code

This needs an install where you choose the plugins: a self-hosted one built with discourse_docker, where you list them in containers/app.yml and rebuild, or a host that installs plugins from your own repository. Discourse’s own hosting lists unofficial and custom plugins on its Enterprise plan only, after its staff review the code; other hosts set their own rules (Communiteq, for one, takes a plugin from your GitHub repository on its Business and Enterprise plans). If your host will not run the fork, plan to turn the plugin off when Google’s service ends; Discourse’s team points to the AI triage in its Discourse AI plugin instead.

2. Make an Unprofane key for each environment

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.

3. Fork the plugin and change one line

Fork github.com/discourse/discourse-perspective-api and change lib/discourse_perspective.rb. Leave ANALYZE_COMMENT_ENDPOINT as it is: the plugin sends /v1alpha1/comments:analyze to the domain, and that is our path. Fork from the commit your Discourse version uses: the plugin’s .discourse-compatibility pins older Discourse versions to older commits, and each of them hardcodes the same line.

-  GOOGLE_API_DOMAIN = "https://commentanalyzer.googleapis.com"
+  GOOGLE_API_DOMAIN = "https://api.unprofane.com"

4. On staging: point the container at your fork

In containers/app.yml, replace the plugin’s clone line with your fork. Your fork no longer receives upstream fixes; watch the upstream repository and rebase onto it.

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/YOUR_ORG/discourse-perspective-api.git

5. Rebuild and confirm the line

The site is offline while the container rebuilds. Then look at the file inside the container: it should name the Unprofane host.

cd /var/discourse && ./launcher rebuild app
./launcher enter app
grep GOOGLE_API_DOMAIN /var/www/discourse/plugins/discourse-perspective-api/lib/discourse_perspective.rb

6. Site settings

The key setting keeps Google’s name and holds your Unprofane key, which the plugin sends as ?key=. There is no base URL setting.

perspective_enabled:        true
perspective_google_api_key: up_test_YOUR_KEY
perspective_toxicity_model: standard

7. Check it from the server, then with a post

Run this from the Discourse host, then post a reply with a plain insult on staging and look for the moderator flag. Both checks matter: when the answer is not a score (a wrong key, a 404, an error), the plugin reads it as 0.0 and flags nothing, with no error. Only a network failure or a read longer than 3 seconds raises a NetworkError in /logs.

curl -s -X POST "https://api.unprofane.com/v1alpha1/comments:analyze?key=up_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"comment":{"text":"you are a clown"},"requestedAttributes":{"TOXICITY":{}},"languages":["en"],"doNotStore":true}'

8. Set the thresholds on staging

perspective_flag_post_min_toxicity (0.9 by default) flags a post scoring above it; perspective_notify_posting_min_toxicity (0.85 by default) warns in the composer when that check is on. Both are between 0 and 1. 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.

9. Then production

Rebuild production from the same fork and commit, and set the live key.

perspective_google_api_key: up_live_YOUR_KEY

What carries over, and what does not

Carries over

  • The path /v1alpha1/comments:analyze, the request body and the response shape: attributeScores with summaryScore and spanScores, languages, detectedLanguages.
  • The error envelope (code, message, status) and Google’s words for each refusal, with Google’s status.
  • The key as ?key=, the first one when a client sends two, or as an X-Goog-Api-Key header.
  • comments:suggestscore, answered with {} as Google answered it.
  • The body the plugin sends: TOXICITY (the standard model) or SEVERE_TOXICITY (the experimental one) with scoreType PROBABILITY, sessionId and doNotStore. The plugin trims a post to 20 KB, well inside this route’s limit.

Not supported

  • The other New York Times attributes (LIKELY_TO_REJECT, SPAM, INFLAMMATORY and the rest) and the bridging attributes are not scored: a request for one is refused as Google refused an attribute it did not know, or left out with dropUnsupportedAttributes.
  • A moderator’s score sent to suggestscore is kept as a correction on your account, beside the score we gave, and read by a person; it changes no score until a later engine.
  • Google’s account errors (a key restricted to a referrer or an address, the API not enabled, billing) have no counterpart: a key here is valid or it is not.
  • A host setting: the plugin has none, so perspective_google_api_key alone still sends the key to Google.

Scored differently

  • The scores come from a different engine: the rules give each attribute a floor from the matched words and the model’s reading lifts the rest. Until the Civil Comments calibration ships, the scale is the engine’s own rather than a fit to Perspective’s.
  • A RAW score is the same number as the probability.
  • Some comments Google refused are scored: languages it did not score (Hebrew, Turkish and others), SEXUALLY_EXPLICIT outside English, and HTML comments read without their tags.

Roll back

Point app.yml back at github.com/discourse/discourse-perspective-api, rebuild, and put your Google key back in perspective_google_api_key. This works until Google’s service ends on December 31, 2026; after that, rolling back means turning perspective_enabled off.

          - git clone https://github.com/discourse/discourse-perspective-api.git

How it was tested

Tested with Discourse 2026.10.0-latest itself (commit a329d97, Ruby 3.4.11) and the plugin at commit 53ece46 with this one-line change and these site settings, run in Discourse’s development image against a local Unprofane API on October 13, 2026. The plugin’s own jobs flagged an insult and not a thanks, flagged an edit, left private messages and a secured category alone until their settings were on, its composer endpoint warned, backfill recorded the scores, and a wrong key flagged nothing without an error. The same run passed against the real model on October 13, 2026, and the rollback below against Google’s own API on October 13, 2026. The snippet checks run the plugin’s own Ruby, with this change, on every run.

Then

Sources