The change
client = discovery.build(
"commentanalyzer", "v1alpha1",
developerKey=LAYAHOST_API_KEY,
discoveryServiceUrl="https://layahost.com/$discovery/rest?version=v1alpha1",
static_discovery=False,
)
Plain HTTP clients change commentanalyzer.googleapis.com to layahost.com and nothing else. The key can stay in ?key=.
Perspective vs layahost
| Perspective API | layahost | |
|---|---|---|
| Status | Shuts down 31 December 2026; no new projects since February 2026 | Available now |
| API | comments:analyze, comments:suggestscore | Same methods and shapes, plus a discovery document for googleapiclient |
| Attributes | 6 production attributes plus experimental ones | TOXICITY, SEVERE_TOXICITY, IDENTITY_ATTACK, INSULT, PROFANITY, THREAT, SEXUALLY_EXPLICIT |
| Scores | Probability that a reader finds the comment toxic | The same meaning, calibrated on the Civil Comments rater labels |
| Price | Free | $5 per million attribute scores; $1 free credit on sign-up |
| Hosting | Google Cloud | EU (Helsinki, Finland); comment text is not stored |
| Model | Jigsaw’s proprietary models | Laya, open source (Apache-2.0) |
Be honest with yourself about accuracy
Perspective’s models were built for exactly this job. Ours is a general decision model, prompted and calibrated for each attribute. On held-out Civil Comments data, TOXICITY reaches a ROC AUC of 0.92; all attributes are listed in the docs. The same comment will get a different number than it did on Perspective, and your best threshold will move. Score a few hundred of your own comments, compare, and pick thresholds from our scores before switching production.
When to choose something else
- Images or video. layahost scores text only.
- Many languages with equal quality. Laya is English-first; other languages are scored, but less accurately.
- A full moderation workflow with review queues, appeals and moderator seats. That is a different kind of product; layahost is the scoring API underneath.
What it costs
Each requested attribute is one decision. Scoring a million comments for TOXICITY costs $5; asking for all 7 attributes costs $35. Credit is prepaid, never expires, and failed requests are free. Verifying your email adds $1 to test with, about 200K scores.
FAQ
Is layahost affiliated with Google or Jigsaw?
No. layahost is an independent service. “Perspective API” is Google’s product name, used here only to describe API compatibility.
Do you store the comments?
No. Comments are processed in memory. Logs keep the scores and metadata for 7 days, and doNotStore is honoured. Details in Data & privacy.
What about suggestscore?
It is accepted and free, so your feedback code keeps running, but nothing is stored or used for training.
Can I test before paying?
Yes. Create an account, verify your email and you get $1 of credit. No card needed.