DEV Community

Cover image for How to Detect AI-Generated Content in Your App (Node.js + Python Examples)
One
One

Posted on

How to Detect AI-Generated Content in Your App (Node.js + Python Examples)

If you're building anything that handles user-submitted text — a CMS, an EdTech platform, a publishing tool — you probably need to know if that text was written by AI.

I built ContentKit AI to solve this. It's a REST API that takes text in and tells you whether it's AI-generated, with a confidence score and specific signals.

Here's how to integrate it in under 5 minutes.

Node.js Example

const axios = require('axios');

const options = {
method: 'POST',
url: 'https://contentkit-ai.p.rapidapi.com/detect',
headers: {
'Content-Type': 'application/json',
'X-RapidAPI-Key': 'YOUR_KEY_HERE',
'X-RapidAPI-Host': 'contentkit-ai.p.rapidapi.com'
},
data: {
text: 'Artificial intelligence has become an integral part of modern society. Furthermore, it is important to note that machine learning algorithms continue to evolve at an unprecedented rate.'
}
};

const response = await axios.request(options);
console.log(response.data);

// Response:
// {
// "ai_score": 90,
// "human_score": 10,
// "verdict": "likely_ai",
// "signals": ["Repetitive transition phrases", "Uniform sentence structure"],
// "confidence": "high"
// }

Python Example

import requests

url = "https://contentkit-ai.p.rapidapi.com/detect"
headers = {
"Content-Type": "application/json",
"X-RapidAPI-Key": "YOUR_KEY_HERE",
"X-RapidAPI-Host": "contentkit-ai.p.rapidapi.com"
}
payload = {
"text": "Artificial intelligence has become an integral part of modern society. Furthermore, it is important to note that machine learning algorithms continue to evolve."
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

What the API Actually Analyzes

The detection endpoint looks at several signals:

  • Sentence structure uniformity — AI writes very evenly, humans vary dramatically
  • Transition phrase patterns — "Furthermore", "Moreover", "It is important to note" are classic AI tells
  • Vocabulary diversity — AI tends to stay in a safe range
  • Burstiness — humans mix 5-word punches with 30-word flowing sentences, AI keeps it uniform
  • Hedging language — "It should be noted that" type phrases

But Wait, There's More

The API also has 3 other endpoints:

/humanize — Takes AI text and rewrites it to sound human. Actually restructures sentences, doesn't just swap synonyms.

/rewrite — Rewrite any text in 8 different tones (formal, casual, academic, professional, friendly, persuasive, simple, technical).

/readability — Returns a readability score, grade level, and specific issues with suggestions.

Try It

Free tier on RapidAPI — 10 requests/month, no credit card needed.

(https://rapidapi.com/agencyonemediaonline/api/contentkit-ai)

Built with Node.js, Express, and Groq's llama-3.3-70b. The whole thing costs me $3/month to run.

If you're building something that handles text content, this might save you from building your own detection/humanization pipeline from scratch.

Top comments (0)