TextSight SDK

AI detector API for Node.js and TypeScript

Add AI-content detection to a web app, CMS, LMS or chat bot with the free textsight npm package. It wraps the TextSight API, ships TypeScript types and has no dependencies.

Install

npm install textsight

Requires Node.js 18 or newer (it uses the built-in fetch).

Detect AI text

import { TextSight } from "textsight";

const ts = new TextSight({ apiKey: process.env.TEXTSIGHT_API_KEY });
const r = await ts.detect(text);

console.log(r.verdict, r.humanization_score);
const flagged = r.sentences.filter((s) => s.label === "ai");

Example: an Express endpoint

import express from "express";
import { TextSight, TextSightError } from "textsight";

const app = express();
const ts = new TextSight();            // reads TEXTSIGHT_API_KEY
app.use(express.json());

app.post("/check", async (req, res) => {
  try {
    const r = await ts.detect(req.body.text);
    res.json({ verdict: r.verdict, score: r.humanization_score });
  } catch (e) {
    if (e instanceof TextSightError) return res.status(e.status || 502).json({ error: e.message });
    throw e;
  }
});
app.listen(3000);

Keep the API key on the server. Never ship it in browser JavaScript.

Humanize AI writing

const out = await ts.rewrite(text, { tone: "blog", strength: 3, preserve: ["ACME Inc."] });
console.log(out.rewritten);

Errors and retries

Failed calls throw TextSightError with status, code and message. Rate limits (429) and brief outages (503) are retried twice with backoff before the error is thrown. Timeouts default to 60 seconds and can be changed with the timeout option.

No-code option: TextSight also connects through Zapier.

FAQ

Is there an AI detector API for JavaScript?

Yes. Install textsight from npm and call new TextSight().detect(text) to get a verdict, a 0-100 humanization score and per-sentence labels.

Can I call the TextSight API from the browser?

You should not, because it would expose your API key. Call it from your server or a serverless function and pass the result to the browser.

Does the npm package support TypeScript?

Yes. Type definitions for every request option and response field are included.