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.2

Published

Lightweight SDK for monitoring AI API costs with Aethermind

Readme

@aethermind/agent

Lightweight SDK for real-time AI API cost monitoring.

🚀 Installation

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

⚡ Quick Start

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

// 1. Initialize Aethermind (once at app startup)
initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY!, // Get from dashboard.aethermind.io
  endpoint: "https://aethermindapi-production.up.railway.app",
});

// 2. Use OpenAI normally - monitoring happens automatically!
const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const completion = await openai.chat.completions.create({
  model: "gpt-3.5-turbo",
  messages: [{ role: "user", content: "Hello!" }],
});

// 3. View costs in real-time at dashboard.aethermind.io
console.log(completion.choices[0].message.content);

That's it! Costs are tracked automatically.

✨ Features

  • 🎯 Zero Config - Works out of the box with OpenAI SDK
  • < 5ms Overhead - Imperceptible latency impact
  • 🔄 Auto-Batching - Efficient telemetry transmission every 30s
  • 🛡️ Resilient - Never crashes your app, even if API is down
  • 📊 Real-time Dashboard - See costs as they happen
  • 🔌 Multi-Provider - OpenAI, Anthropic (more coming soon)

📖 Configuration

Basic Usage

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

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

CommonJS Usage

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

initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY,
  endpoint: "https://aethermindapi-production.up.railway.app",
});

Configuration Options

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

📚 Examples

OpenAI Integration

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

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

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

// All calls are automatically tracked
const response = await openai.chat.completions.create({
  model: "gpt-4",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "What is TypeScript?" },
  ],
});

Anthropic Integration

import Anthropic from "@anthropic-ai/sdk";
import { initAethermind } from "@aethermind/agent";

// Initialize Aethermind
initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY!,
});

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

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

Disable Monitoring in Development

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

initAethermind({
  apiKey: process.env.AETHERMIND_API_KEY!,
  enabled: process.env.NODE_ENV === "production", // Only track in prod
});

🔧 Troubleshooting

Events not appearing in dashboard?

  1. Wait 30 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

🎯 How It Works

  1. Instrumentation - SDK patches OpenAI/Anthropic clients
  2. Event Capture - Captures model, tokens, cost, latency on each call
  3. Batching - Events batched locally (default: 50 events or 30s)
  4. Async Transmission - Sent to Aethermind API in background
  5. Zero Impact - No blocking, no errors thrown to your app

📚 Documentation

🤝 Support

📄 License

MIT © Aethermind Team


Built with ❤️ for developers who care about AI costs