llm-lens-sdk
v0.1.4
Published
Sub-millisecond, local-first OpenTelemetry observability SDK for LLMs. Features native Vercel AI SDK integration.
Maintainers
Readme
LLM Lens is a blazing-fast, developer-first alternative to cloud AI observability platforms. It intercepts traces at runtime and pipes them directly to a local, WAL-optimized SQLite daemon with < 1ms latency.
This package (llm-lens-sdk) is the lightweight OpenTelemetry wrapper that instruments your LLM frameworks.
Installation
npm install llm-lens-sdk(Note: You must also run the llm-lens-daemon to receive the traces and view the dashboard).
Usage
LLM Lens integrates seamlessly with popular AI frameworks. First, initialize the telemetry exporter:
Vercel AI SDK (Native OpenTelemetry)
Vercel AI SDK works out-of-the-box using its built-in experimental_telemetry option. initAutopilot automatically registers a fast, lightweight OpenTelemetry provider.
import { initAutopilot } from 'llm-lens-sdk';
import { generateText } from 'ai';
// 1. Initialize telemetry (registers global OTEL provider automatically)
initAutopilot({ serviceName: 'my-vercel-ai-agent' });
// 2. Just use Vercel AI SDK natively with telemetry enabled!
await generateText({
model,
prompt: 'Hello world',
experimental_telemetry: { isEnabled: true } // Vercel handles the rest!
});OpenAI (and Groq)
import { initAutopilot, wrapOpenAI, wrapGroq } from 'llm-lens-sdk';
import OpenAI from 'openai';
import Groq from 'groq-sdk';
initAutopilot({ serviceName: 'my-openai-agent' });
// Wrap the client instance
const openai = wrapOpenAI(new OpenAI({ apiKey: '...' }));
const groq = wrapGroq(new Groq({ apiKey: '...' }));
// ... use openai.chat.completions.create as normal ...For more documentation, visit the main repository.
