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

@neurameter/core

v0.1.9

Published

Core SDK for NeuraMeter — AI agent cost tracking

Readme

@neurameter/core

Core SDK for NeuraMeter — real-time AI agent cost tracking.

Installation

npm install @neurameter/core
# or
pnpm add @neurameter/core

Quick Start

import { NeuraMeter } from '@neurameter/core';

const meter = new NeuraMeter({
  apiKey: 'nm_xxx',
  projectId: 'proj_xxx',
});

// Record a cost event manually
meter.record({
  traceId: 'trace-123',
  spanId: 'span-456',
  agentName: 'SupportAgent',
  provider: 'openai',
  model: 'gpt-4o',
  inputTokens: 1500,
  outputTokens: 800,
  costMicrodollars: 11750,
  latencyMs: 450,
});

// Flush all buffered events before shutdown
await meter.flush();

Multi-Agent Tracing

const meter = new NeuraMeter({ apiKey: 'nm_xxx', projectId: 'proj_xxx' });

// Start a trace for a multi-agent workflow
const trace = meter.startTrace({
  agentName: 'OrchestratorAgent',
  customerId: 'cust_123',
});

// Record spans for each agent call
const parentSpan = trace.span({
  provider: 'openai',
  model: 'gpt-4o',
  usage: { inputTokens: 500, outputTokens: 200 },
  latencyMs: 300,
});

// Child spans
trace.span({
  provider: 'anthropic',
  model: 'claude-sonnet-4-20250514',
  usage: { inputTokens: 1000, outputTokens: 500 },
  latencyMs: 800,
  parentSpanId: parentSpan,
  agentName: 'DraftAgent',
});

With OpenAI / Anthropic SDKs

Use @neurameter/openai or @neurameter/anthropic for automatic instrumentation:

import { NeuraMeter } from '@neurameter/core';
import { withMeter } from '@neurameter/openai';
import OpenAI from 'openai';

const meter = new NeuraMeter({ apiKey: 'nm_xxx', projectId: 'proj_xxx' });
const openai = withMeter(new OpenAI(), meter);

// Automatically tracks tokens, cost, and latency
const response = await openai.chat.completions.create(
  { model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello' }] },
  { agentName: 'SupportAgent', taskName: 'classify-ticket' },
);

CostEvent Type

interface CostEvent {
  eventId: string;           // Auto-generated UUID
  timestamp: string;         // ISO 8601
  traceId: string;           // Groups related spans
  spanId: string;            // Unique span identifier
  parentSpanId?: string;     // Parent span (for tree structure)
  agentName: string;         // Name of the AI agent
  taskName?: string;         // Optional task label
  customerId?: string;       // End-user identifier
  provider: 'openai' | 'anthropic' | 'google' | 'other';
  model: string;             // Model identifier
  inputTokens: number;       // Prompt tokens
  outputTokens: number;      // Completion tokens
  reasoningTokens?: number;  // Reasoning tokens (o1, o3)
  cachedTokens?: number;     // Cached input tokens
  costMicrodollars: number;  // Cost in microdollars (1 USD = 1,000,000)
  latencyMs: number;         // Response latency
  tags?: Record<string, string>;
  orgId: string;             // Organization ID
  projectId: string;         // Project ID
}

Key Design Decisions

  • Zero dependencies — only uses native fetch() and crypto
  • Integer cost arithmetic — all costs in microdollars (no floating-point)
  • Fire-and-forget — SDK errors never propagate to your application
  • Batch sending — events are buffered and sent in batches of 50-100
  • < 5KB gzipped — minimal impact on bundle size