classer-ai
v0.0.1
Published
Low-cost, fast AI classification API
Maintainers
Readme
classer-ai
Low-cost, fast AI classification API. 10x cheaper than GPT, <200ms latency.
Installation
npm install classer-aiQuick Start
import { classify, tag, match, score } from "classer-ai";
// Set your API key
process.env.CLASSER_API_KEY = "your-api-key";
// Classify text into categories
const result = await classify({
source: "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
// Multi-label tagging
const tags = await tag({
source: "Breaking: Tech stocks surge amid AI boom",
labels: ["politics", "technology", "finance", "sports"],
threshold: 0.3
});
console.log(tags.tags); // ["technology", "finance"]
// RAG retrieval scoring
const relevance = await match({
source: "Our return policy allows refunds within 30 days.",
query: "Can I get a refund?"
});
console.log(relevance.score); // 0.98
// Attribute scoring
const urgency = await score({
source: "This is URGENT! We need help immediately!",
attribute: "urgency"
});
console.log(urgency.score); // 0.92Configuration
Environment Variables
CLASSER_API_KEY=your-api-key
CLASSER_BASE_URL=https://api.classer.ai # optionalCustom Client
import { ClasserClient } from "classer-ai";
const classer = new ClasserClient({
apiKey: "your-api-key",
baseUrl: "https://api.classer.ai"
});
const result = await classer.classify({
source: "Hello world",
labels: ["greeting", "question", "statement"]
});API Reference
classify(request)
Classify text into exactly one of the provided labels.
const result = await classify({
source: string, // Text to classify
labels: string[], // 1-26 possible labels
descriptions?: Record<string, string>, // Optional label descriptions
model?: string // Optional model override
});
// Returns
{
label: string, // Selected label
confidence: number, // 0-1 confidence score
latency_ms: number // Processing time
}tag(request)
Multi-label classification - returns all labels above threshold.
const result = await tag({
source: string,
labels: string[],
descriptions?: Record<string, string>,
threshold?: number, // Default: 0.3
model?: string
});
// Returns
{
tags: string[], // Labels above threshold
confidences: number[], // Confidence for each tag
latency_ms: number
}match(request)
Semantic similarity for RAG retrieval.
const result = await match({
source: string, // Document text
query: string, // Search query
model?: string
});
// Returns
{
score: number, // 0-1 relevance score
latency_ms: number
}score(request)
Score text on a specific attribute.
const result = await score({
source: string,
attribute: string, // e.g., "urgency", "toxicity", "quality"
description?: string, // Optional attribute description
model?: string
});
// Returns
{
score: number, // 0-1 score
latency_ms: number
}License
MIT
