infer-sdk
v0.1.3
Published
Node.js SDK for Infer
Downloads
174
Readme
Infer
A powerful, type-safe SDK for ML inference operations.
Installation
npm install infer
Quick Start
import Infer from 'infer';
const infer = new Infer({ apiKey: 'your-api-key' });
const result = await infer.zeroShot.classify(
"I love this product!",
['positive', 'negative']
);
Features
- 🚀 Zero-shot classification
- 💪 Full TypeScript support
- 🔒 Built-in error handling
- ⚡️ Modern ESM and CommonJS support
Documentation
API Reference
Configuration
const infer = new Infer({
apiKey: 'your-api-key',
baseUrl?: 'https://custom-endpoint.com' // Optional
});
Zero-Shot Classification
// Basic usage
const result = await infer.zeroShot.classify(
text: string,
labels: string[]
);
// With options
const result = await infer.zeroShot.classify(
text: string,
labels: string[],
options: ZeroShotOptions
);
Error Handling
import { UnauthorizedError, RateLimitError } from 'infer';
try {
const result = await infer.zeroShot.classify(text, labels);
} catch (error) {
if (error instanceof UnauthorizedError) {
// Handle authentication error
} else if (error instanceof RateLimitError) {
// Handle rate limiting
}
}
Error Types
| Error Class | Description | HTTP Status |
|-------------|-------------|-------------|
| UnauthorizedError
| Invalid API key | 401 |
| RateLimitError
| Too many requests | 429 |
| InferError
| Generic error | Various |
TypeScript Support
Full type definitions included:
import type { ZeroShotResponse, ZeroShotOptions } from 'infer';
const options: ZeroShotOptions = {
multiLabel: true,
};
License
MIT