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

@aethermind/agent

v0.1.6

Published

Lightweight SDK for monitoring AI API costs with Aethermind

Readme

@aethermind/agent

Lightweight SDK for real-time AI API cost monitoring. Works with any setup -- official SDKs, raw fetch(), or any HTTP client that calls OpenAI or Anthropic APIs.

Installation

npm install @aethermind/agent
# or
pnpm add @aethermind/agent
# or
yarn add @aethermind/agent

No peer dependencies required. If you use the official OpenAI or Anthropic Node.js SDKs, the agent will patch those too for deeper telemetry -- but it is entirely optional.

Quick Start

import { initAethermind } from "@aethermind/agent";

// Initialize once at app startup
initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY!,
});

That's it. Every call to api.openai.com or api.anthropic.com is now tracked automatically -- regardless of how you make the request.

Using raw fetch()

// No SDK needed -- fetch() calls are intercepted automatically
const response = await fetch("https://api.openai.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
  },
  body: JSON.stringify({
    model: "gpt-4o",
    messages: [{ role: "user", content: "Hello!" }],
  }),
});

// Costs are tracked in the background
const data = await response.json();
console.log(data.choices[0].message.content);

Using the OpenAI SDK

import OpenAI from "openai";

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// Automatically tracked via SDK patching
const completion = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});

Using the Anthropic SDK

import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

// Automatically tracked via SDK patching
const message = await anthropic.messages.create({
  model: "claude-3-5-sonnet-20241022",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude!" }],
});

How It Works

The SDK uses three layers to capture telemetry with zero code changes:

  1. Fetch interceptor -- Patches globalThis.fetch to detect calls to OpenAI/Anthropic API hostnames. Extracts model, tokens, cost, and latency from the response. Works with any HTTP client that uses fetch() under the hood.

  2. SDK patching -- Monkey-patches OpenAI.chat.completions.create and Anthropic.messages.create prototypes for SDK-specific telemetry (covers streaming and other SDK features). Only activates if the SDKs are installed.

  3. Batch transport -- Captured events are queued locally and flushed to the Aethermind API in batches (default: every 5 seconds or 50 events). Failed events are stored in a dead-letter queue for retry.

Non-LLM fetch calls (e.g. your own API routes) pass through untouched with zero overhead. All telemetry extraction is wrapped in try/catch -- the SDK never throws errors into your application.

Configuration

import { initAethermind } from "@aethermind/agent";

initAethermind({
  apiKey: "your-aethermind-api-key", // Required
  endpoint: "https://aethermind-agentos-production.up.railway.app", // Optional
  flushInterval: 5000, // Optional: ms between flushes (default: 5000)
  batchSize: 50, // Optional: events per batch (default: 50)
  enabled: true, // Optional: enable/disable (default: true)
});

| Option | Type | Default | Description | | --------------- | --------- | --------------------------- | ---------------------------------- | | apiKey | string | required | Your Aethermind API key | | endpoint | string | https://aethermind-agentos-production.up.railway.app | API endpoint URL | | flushInterval | number | 5000 | Milliseconds between batch flushes | | batchSize | number | 50 | Maximum events per batch | | enabled | boolean | true | Enable/disable monitoring |

Disable Monitoring in Development

initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY!,
  enabled: process.env.NODE_ENV === "production",
});

CommonJS Usage

const { initAethermind } = require("@aethermind/agent");

initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY,
});

Troubleshooting

Events not appearing in dashboard?

  1. Wait 5 seconds (default batch interval)
  2. Verify API key is correct: process.env.AETHERMIND_API_KEY
  3. Check endpoint URL is correct
  4. Ensure enabled: true (default)

TypeScript errors?

Make sure you have @types/node installed:

npm install -D @types/node

Want to verify initialization?

The SDK logs to console when initialized:

[Aethermind] SDK initialized successfully

If disabled:

[Aethermind] SDK initialized but disabled

Documentation

Support

License

MIT - Aethermind Team