classer-ai
v0.0.3
Published
High-performance AI classification — <200ms latency, up to 100x cheaper, beats GPT-5 mini accuracy
Maintainers
Readme
classer-ai
High-performance AI classification
<200ms latency · up to 100x cheaper · beats GPT-5 mini accuracy · self-calibrating accuracy · no prompt engineering
Installation
npm install classer-aiQuick Start
import { classify, tag } from "classer-ai";
// Single-label classification
const result = await classify({
text: "I can't log in and need a password reset.",
labels: ["billing", "technical_support", "sales", "spam"]
});
console.log(result.label); // "technical_support"
console.log(result.confidence); // 0.94
// With descriptions for better accuracy
const lead = await classify({
text: "We need a solution for 500 users, what's your enterprise pricing?",
labels: ["hot", "warm", "cold"],
descriptions: {
hot: "Ready to buy, asking for pricing or demo",
warm: "Interested but exploring options",
cold: "Just browsing, no clear intent"
}
});
console.log(lead.label); // "hot"
// Multi-label tagging
const tagged = await tag({
text: "Breaking: Tech stocks surge amid AI boom",
labels: ["politics", "technology", "finance", "sports"],
threshold: 0.3
});
for (const t of tagged.labels) {
console.log(`${t.label}: ${t.confidence}`);
}
// technology: 0.92
// finance: 0.78Configuration
No API key is needed to get started. To unlock higher rate limits, get an API key from classer.ai/api-keys.
export CLASSER_API_KEY=your-api-keyOr configure programmatically:
import { ClasserClient } from "classer-ai";
const client = new ClasserClient({
apiKey: "your-api-key"
});API Reference
classify(request)
Classify text into exactly one of the provided labels.
const result = await classify({
text: string, // Text to classify
labels?: string[], // 1-200 possible labels
classifier?: string, // Saved classifier name or "name@vN"
descriptions?: Record<string, string>,
speed?: "fast" | "standard", // "standard" (default, <1s) or "fast" (<200ms)
cache?: boolean // Set to false to bypass cache. Default: true
});
// Returns ClassifyResponse
result.label // Selected label
result.confidence // 0-1 confidence score
result.tokens // Total tokens used
result.latency_ms // Processing time in ms
result.cached // Whether served from cachetag(request)
Multi-label tagging — returns all labels above a confidence threshold.
const result = await tag({
text: string,
labels?: string[], // 1-200 possible labels
classifier?: string, // Saved classifier name or "name@vN"
descriptions?: Record<string, string>,
threshold?: number, // Default: 0.3
speed?: "fast" | "standard", // "standard" (default, <1s) or "fast" (<200ms)
cache?: boolean // Set to false to bypass cache. Default: true
});
// Returns TagResponse
result.labels // Array of { label, confidence }
result.tokens // Total tokens used
result.latency_ms // Processing time in ms
result.cached // Whether served from cacheError Handling
import { ClasserError } from "classer-ai";
try {
const result = await classify({ text: "hello", labels: ["a", "b"] });
} catch (e) {
if (e instanceof ClasserError) {
console.error(e.status); // HTTP status code
console.error(e.detail); // Error detail from API
}
}Documentation
Full API reference and guides at docs.classer.ai.
GitHub
github.com/classer-ai/classer-js
License
MIT
