Guide
Content Moderation
Filter toxic reviews automatically with Perspective API or OpenAI.
nuxt-reviews includes built-in content moderation to automatically filter or flag toxic reviews.
Setup
nuxt.config.ts
reviews: {
moderation: {
enabled: true,
provider: 'perspective',
apiKey: process.env.PERSPECTIVE_API_KEY,
toxicityThreshold: 0.7,
action: 'filter'
}
}
Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable content moderation |
provider | 'perspective' | 'openai' | — | Moderation provider |
apiKey | string | — | Provider API key |
toxicityThreshold | number | 0.7 | Score threshold (0.0 - 1.0) |
attributes | PerspectiveAttribute[] | All | Perspective API only |
action | 'filter' | 'flag' | 'filter' | Action on flagged reviews |
Filter vs Flag
Filter Mode
Toxic reviews are removed from the response entirely:
moderation: {
action: 'filter' // Toxic reviews are excluded
}
Flag Mode
Reviews are kept but include moderation metadata:
moderation: {
action: 'flag' // Reviews include moderation data
}
In flag mode, each review includes a moderation field:
{
"moderation": {
"flagged": true,
"provider": "perspective",
"scores": {
"toxicity": 0.85,
"severeToxicity": 0.12,
"insult": 0.78,
"profanity": 0.65,
"threat": 0.02,
"identityAttack": 0.05
}
}
}
Perspective API Attributes
moderation: {
attributes: ['TOXICITY', 'SEVERE_TOXICITY', 'INSULT', 'PROFANITY']
}
Available: TOXICITY, SEVERE_TOXICITY, INSULT, PROFANITY, THREAT, IDENTITY_ATTACK.