Why Comment Moderation Again?
My personal blog doesn't get much traffic—just a few dozen comments a day. But the proportion of spam hovers around 30% year-round: promotional links, bot flooding, and meaningless copy-paste. I used to spend 20 minutes every morning cleaning it up, plus another review in the evening—about 40 minutes a day in total. That's 20 hours a month, the equivalent of two full workdays.
The problem with manual moderation isn't just the time cost—there's also the delay: genuine reader questions would sit in the comment section for hours before being approved, which makes for a terrible experience.
Later, I handed this task over to an AI whitelist model: only comments classified as high-confidence normal content get approved automatically; everything else goes into a manual review queue. The results:
- Manual intervention time dropped from about 40 minutes to about 5 minutes per day
- Average approval time for normal comments went from hours to seconds
- The false-positive rate is kept within acceptable bounds thanks to the whitelist strategy—suspicious comments aren't deleted outright, they just go into the queue
This post documents the complete integration process, from signing up to getting your first code running—in theory, under 30 minutes.
What Is the Whitelist Model Strategy
Let's clarify the concept first. The common moderation approach is a blacklist: block clearly spammy content and let everything else through. A whitelist flips this: only comments the model judges as high-confidence normal content get auto-approved; everything else goes into the manual queue.
For a personal blog, the whitelist strategy has one key advantage: the cost of false positives is very low. If a normal comment is mistakenly sent to the queue, you just click approve manually; but if a spam comment slips through to the front page, it degrades the experience for every reader. Better to over-review than to let spam through.
You can save even more money by combining model tiers: high-confidence judgments can be handled by a lightweight model, reserving the stronger models only for ambiguous cases. I've covered the specific tiered configuration approach in detail in a previous post, so I won't repeat it here.
Step 1: Register on ThisToken.AI and Get an API Key
- Open the ThisToken.AI website, click register, and verify your email to create your account
- After logging in, go to the console and find the "API Keys" page
- Click "Create Key", give the key a name (e.g.,
blog-comment-check), and copy the generated secret string
Note: The key is only displayed in full once at creation. Be sure to save it somewhere secure immediately, and never commit it to your code repository. Managing it via environment variables is recommended:
export THISTOKEN_API_KEY="sk-你的密钥"As for pricing, ThisToken.AI uses pay-as-you-go billing—see the official pricing page for details. At personal blog scale (dozens to a hundred calls per day), the cost is usually negligible, but I recommend setting a spending cap in the console to avoid unexpected losses if your key leaks.
Step 2: Get Your First Code Running
Install the dependency:
pip install openaiThisToken.AI's API is compatible with the OpenAI SDK format—you only need to change base_url. Here's a complete, ready-to-run piece of code:
import os
from openai import OpenAI
# 指向 ThisToken.AI 的网关
client = OpenAI(
api_key=os.environ["THISTOKEN_API_KEY"],
base_url="https://api.thistoken.ai/v1",
)
SYSTEM_PROMPT = """你是博客评论审核员,采用白名单策略。
只有限定内容才可放行:与文章相关的讨论、真诚的提问、合理的补充意见。
输出严格的 JSON:{"verdict": "pass" | "review", "reason": "一句话理由"}
没有把握时一律输出 review,不要放行。"""
def check_comment(text: str) -> dict:
resp = client.chat.completions.create(
model="gpt-4o-mini",
temperature=0,
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"待审核评论:\n{text}"},
],
)
import json
return json.loads(resp.choices[0].message.content)
if __name__ == "__main__":
samples = [
"这篇文章的缓存策略部分写得很清楚,请问LRU淘汰的阈值可以配置吗?",
"加微信xxx免费领取资料,日入过千不是梦!",
]
for s in samples:
result = check_comment(s)
print(f"[{result['verdict']}] {result['reason']} <- {s[:20]}...")Run it:
python check.pyExpected output looks something like:
[pass] 与文章内容相关的技术提问 <- 这篇文章的缓存策略部分写得很...
[review] 含推广引流信息,疑似垃圾评论 <- 加微信xxx免费领取资料...A few implementation details worth noting:
- temperature=0: moderation requires consistency, not creativity
- Whitelist instructions in the system prompt: "when in doubt, always output review"—this line is the key to reducing missed spam
- JSON output format: makes programmatic parsing easy, avoiding the fragility of regex-matching natural language
Step 3: Integrate into Your Blog's Comment Workflow
Once it's working, hook it into your comment submission flow. Here's a typical comment processing pipeline:
- Comment submitted → first run local rules (length, frequency, keywords) to block obvious spam
- Local rules pass → call the
check_commentfunction above pass→ approve and display immediatelyreview→ put into the pending queue and send you a notification
The local rules layer is important: it blocks a fair share of low-grade spam at zero cost, reserving API calls for content that genuinely needs judgment. After this two-layer filtering, I typically only need to manually handle three to five comments per day.
Also remember to handle API timeouts and errors: if the moderation service is unavailable, default to the manual queue rather than auto-approving, to keep the whitelist strategy consistent.
The Bottom Line on Efficiency
Before vs. after integration:
| Metric | Before | After |
|---|---|---|
| Daily manual moderation time | ~40 minutes | ~5 minutes |
| Approval delay for normal comments | Hours | Seconds |
| Missed spam comments | Occasional | Virtually zero |
That's roughly 17–18 hours saved per month. For an indie developer, that's enough time to write a new article, or finally fix those long-standing bugs in your backlog. As for API costs—per the official pricing page, at personal blog call volumes it's usually far less than any price you'd pay for the time saved.
The whole integration process took me under half an hour, half of which was spent tuning the prompt. If you're also plagued by comment spam, you can start right now: the registration link is here: https://api.thistoken.ai/register
---
Ready to try it yourself? Sign up at https://api.thistoken.ai/register to get your API key and start building.
Vous voulez essayer Token.AI ?
Créez une API Key au niveau du projet, activez les canaux dans la console et configurez le routage, les budgets et les journaux d'audit.
注册 ThisToken.AI 并获取 API Key