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

@kalaa/node

v1.1.1

Published

Drop-in AI cost tracking for Node.js and TypeScript. Auto-instruments OpenAI, Anthropic, and Gemini at the class level, with zero code at each call site.

Downloads

537

Readme

kalaa

Drop-in AI cost tracking for Node.js and TypeScript. Patches the OpenAI, Anthropic, and Gemini client libraries at the class level, so every client you create — before or after observe(), anywhere in your app — is already instrumented. No wrapping, no manual logging per call.

Install

npm install @kalaa/node

Setup

const kalaa = require('@kalaa/node');
kalaa.observe({ key: process.env.KALAA_KEY });

Or in TypeScript / ESM:

import kalaa from '@kalaa/node';
kalaa.observe({ key: process.env.KALAA_KEY });

That's it. Put KALAA_KEY=cm_live_xxx in your .env and every OpenAI, Anthropic, and Gemini call your app makes from here on is tracked automatically — including the user who made the request, with zero extra code, if you're running Express (route + user attribution wire themselves in automatically).

Tagging a user manually

Automatic detection covers most setups (reads x-user-id, a decoded JWT, or a client-side anonymous id). If yours doesn't fit that shape, tag it explicitly:

kalaa.setUser(currentUser.id);

Background jobs / cron

No request to hang a route off of, so give it a label instead:

kalaa.withContext('nightly-digest', () => {
  runTheJob();
});

What's tracked automatically

  • OpenAI: chat completions, including streaming (stream_options.include_usage)
  • Anthropic: messages, including streaming
  • Gemini: generateContent and generateContentStream — both @google/genai (current) and @google/generative-ai (legacy) are supported
  • Whisper/audio transcription duration

Order matters for Gemini: call kalaa.observe() before you require('@google/genai') anywhere in your app. (OpenAI and Anthropic aren't order-sensitive — only the current Gemini SDK's instance-bound methods require this.)

Configuration

| Option | Env var | Default | |---|---|---| | key | KALAA_KEY | — | | endpoint | KALAA_ENDPOINT | https://api.kalaa.cc/api/ingest | | env | KALAA_ENV | NODE_ENV | | debug | KALAA_DEBUG=1 | false |

Failure behavior

This package never touches a database and never sits in the path of your AI calls. If the ingest endpoint is unreachable, events are buffered and retried on the next flush cycle — your app is never blocked or crashed by a tracking failure.

License

MIT