SDK Reference
@neurameter/core is the core SDK for NeuraMeter. It provides cost tracking, context analysis, and guardrails for AI agent applications.
Installation
npm install @neurameter/corePackage Exports
// OpenAI client wrapper (recommended for most users)
import { withNeuraMeter } from '@neurameter/core';
// Core classes
import { NeuraMeter, Trace } from '@neurameter/core';
// Cost calculation
import { calculateCostMicrodollars, getModelPricing } from '@neurameter/core';
// Context analysis
import { analyzeContext, estimateTokens, getModelContextLimit } from '@neurameter/core';
// Guardrails
import { checkGuards, NeuraMeterGuardError } from '@neurameter/core';
// Savings calculation
import { calculateSaving } from '@neurameter/core';Design Principles
- Zero dependencies — Uses only native
fetch()andcrypto - Fire-and-forget — SDK errors never propagate to your application code
- Batch sending — Events buffered and sent in batches (50 events or 5s interval)
- Integer arithmetic — All costs in microdollars ($1 = 1,000,000). No floating-point rounding errors.
- Dual format — ESM and CJS via tsup
Quick Links
- withNeuraMeter() — Wrap an OpenAI client for automatic tracking
- NeuraMeter Class — Low-level event recording and guard checks
- Trace — Group related events into traces