is-it-spam
v0.1.2
Published
LLM-based spam classifier. Works with any OpenAI-compatible API.
Maintainers
Readme
is-it-spam
LLM-based spam classifier. Works with any OpenAI-compatible API.
Install
npm i is-it-spamUsage
import { createClassifier } from "is-it-spam";
const isSpam = createClassifier({
apiKey: process.env.OPENROUTER_API_KEY!,
zdr: true
});
if (await isSpam("Need a quote for your services")) {
// spam
}
// or get details
const result = await isSpam.details("Need a quote");
// { isSpam: false, confidence: 0.95, reason: "..." }Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | required | API key |
| model | string | openai/gpt-5.4-nano | Model to use |
| baseUrl | string | OpenRouter | API endpoint |
| zdr | boolean | false | Zero Data Retention |
Providers
Works with any OpenAI-compatible API:
// OpenRouter (default)
const isSpam = createClassifier({ apiKey: process.env.OPENROUTER_API_KEY! });
// OpenAI
const isSpam = createClassifier({
apiKey: process.env.OPENAI_API_KEY!,
baseUrl: "https://api.openai.com/v1/chat/completions",
model: "gpt-4o-mini",
});
// Local LLM
const isSpam = createClassifier({
apiKey: "not-needed",
baseUrl: "http://localhost:11434/v1/chat/completions",
model: "llama3",
});Fail-Safe
Returns false (legitimate) if the API fails, so you never block real customers.
Cost
~$0.0002 per check. 10,000 checks = ~$2.
License
MIT
