@useobsrvai/sdk
v1.0.1
Published
ObsrvAI SDK — AI observability and business intelligence for SaaS and AI products
Maintainers
Readme
@useobsrvai/sdk
AI observability and business intelligence SDK for SaaS and AI products. Track LLM calls, agents, RAG pipelines, events, errors, and more — with zero overhead when disabled.
Install
npm install @useobsrvai/sdk
# or
pnpm add @useobsrvai/sdkQuick Start
import { ObsrvAI } from '@useobsrvai/sdk';
const obs = new ObsrvAI({
apiKey: 'oai_your_api_key',
baseUrl: 'https://your-collector.example.com', // or http://localhost:3001 for self-hosted
});
// Track an LLM call
const call = obs.llm.start({ model: 'gpt-4o', prompt: 'Hello!' });
const response = await openai.chat.completions.create({ ... });
call.end({ response });
// Track a user event
obs.events.track({ userId: 'user_123', event: 'feature_used', properties: { feature: 'export' } });
// Capture an error
obs.errors.capture(err, { userId: 'user_123' });
// Track a RAG retrieval
const rag = obs.rag.start({ queryText: 'What is RAG?', collection: 'docs' });
const chunks = await vectorStore.search(...);
rag.end({ chunksRetrieved: chunks.length, topScore: chunks[0].score });
// Track an agent session
const session = obs.agent.startSession({ agentName: 'researcher', goal: 'Summarise topic' });
const step = session.startStep({ stepType: 'tool_call' });
step.end({ success: true });
session.end({ success: true });Disable for Testing
const obs = new ObsrvAI({ apiKey: '...', enabled: false }); // zero overhead, no network calls