npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

loglens-sdk

v0.4.5

Published

AI observability SDK — wraps Anthropic and OpenAI clients and logs every request

Readme

loglens-sdk

See exactly what your AI is doing. LogLens is a lightweight LLM observability SDK that intercepts every Anthropic and OpenAI call your app makes and logs the prompt, completion, latency, token count, cost, and errors to a real-time dashboard — with one line of code.

No proxy. No framework lock-in. Works with your existing client.


Install

npm install loglens-sdk

Quick start

Sign up at llm-watch.vercel.app and grab your API key from Settings, then wrap your existing client:

Anthropic

import Anthropic from "@anthropic-ai/sdk";
import { wrapAnthropic } from "loglens-sdk";

const anthropic = wrapAnthropic(new Anthropic(), {
  apiKey: "lw_live_your_key",   // from LogLens Settings
  projectId: "my-app",          // optional
});

// Use the client exactly as before — every call is now logged
const msg = await anthropic.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

OpenAI

import OpenAI from "openai";
import { wrapOpenAI } from "loglens-sdk";

const openai = wrapOpenAI(new OpenAI(), {
  apiKey: "lw_live_your_key",
  projectId: "my-app",
});

const res = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello" }],
});

Then open your dashboard and watch the calls appear in real time.


Options

| Option | Type | Description | | --- | --- | --- | | apiKey | string | Your LogLens API key (required). | | projectId | string | Label calls by project or feature for filtering. | | userId | string | Attribute calls to a specific end user. | | sessionId | string | Group calls belonging to the same session. | | tags | string[] | Arbitrary labels, e.g. ["prod", "chat"]. | | maskPrompts | boolean | When true, prompt and completion text is replaced with [masked] before leaving your app — only metadata (latency, tokens, cost) is sent. |

const anthropic = wrapAnthropic(new Anthropic(), {
  apiKey: "lw_live_your_key",
  projectId: "support-bot",
  userId: req.user.id,
  tags: ["prod"],
  maskPrompts: true, // privacy-first: send metadata only
});

What gets logged

Every call records:

  • Prompt and completion text (unless maskPrompts is enabled)
  • Model name
  • Latency in milliseconds
  • Token usage — input and output
  • Cost in USD, computed from a built-in pricing table
  • Errors — failed calls log the error type and message

How it works

The SDK wraps your existing client in place, so your TypeScript types and method calls are unchanged. Telemetry is sent fire-and-forget — a slow or unreachable LogLens endpoint will never block or crash your app. Streaming responses are fully supported, including exact token counts captured after the stream completes.


Streaming notes

  • Anthropic: messages.stream() and messages.create({ stream: true }) are both supported. Token counts are captured exactly from the final message.
  • OpenAI: for accurate token counts on streamed responses, pass stream_options: { include_usage: true } in your request.

Privacy

LogLens stores prompt and completion text to power the dashboard. If you handle sensitive data, enable maskPrompts: true to send only metadata, or review the data handling page. Configurable log retention is available in your account settings.


Links

License

MIT