0.1.7 • Published 4 months ago
l1m v0.1.7
l1m Node SDK
Node.js SDK for the l1m API, enabling you to extract structured, typed data from text and images using LLMs.
By default, the managed l1m service is used, self-hosting details are available here.
Installation
npm install l1m
Usage
import L1M from 'l1m';
import { z } from 'zod';
const l1m = new L1M({
//baseUrl: "http://localhost:10337", Optional if self-hosting l1m server
provider: {
model: "claude-3-opus-20240229",
url: "https://api.anthropic.com/v1/messages",
key: "your-api-key"
}
});
// Extract structured data
const result = await l1m.structured({
input: "John Smith was born on January 15, 1980. He works at Acme Inc. as a Senior Engineer and can be reached at john.smith@example.com or by phone at (555) 123-4567.",
// OR input: "<BASE64_ENCODED_IMAGE>",
instructions: "Extract details from the provided text", // Optional
schema: z.object({
name: z.string(),
company: z.string(),
contactInfo: z.object({
email: z.string(),
phone: z.string()
})
})
}, {
cacheTTL: 60 // Optional
});
Development
# Build the SDK
npm run build
# Run tests
npm run test