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

@with-orbit/sdk

v0.1.3

Published

Orbit - AI Cost Analytics SDK. Track, monitor, and optimize your AI spend.

Readme

Orbit SDK

Track, monitor, and optimize your AI spend across OpenAI, Anthropic, and other LLM providers.

Installation

npm install @with-orbit/sdk
# or
yarn add @with-orbit/sdk
# or
pnpm add @with-orbit/sdk

Quick Start

1. Get your API key

Sign up at Orbit and create an API key.

2. Initialize the SDK

import { Orbit } from '@with-orbit/sdk';

const orbit = new Orbit({
  apiKey: 'orb_live_xxxxxxxxxxxxxxxxxxxxxxxx',
  defaultFeature: 'my-app', // Optional: default feature for all events
});

3. Track your LLM calls

Option A: Automatic tracking (Recommended)

Wrap your OpenAI or Anthropic client for automatic tracking:

import OpenAI from 'openai';
import { Orbit } from '@with-orbit/sdk';

const orbit = new Orbit({ apiKey: 'orb_live_xxx' });
const openai = orbit.wrapOpenAI(new OpenAI(), {
  feature: 'chat-assistant', // Attribute all calls to this feature
});

// All API calls are now automatically tracked!
const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello, world!' }],
});

Works with Anthropic too:

import Anthropic from '@anthropic-ai/sdk';
import { Orbit } from '@with-orbit/sdk';

const orbit = new Orbit({ apiKey: 'orb_live_xxx' });
const anthropic = orbit.wrapAnthropic(new Anthropic(), {
  feature: 'document-analysis',
});

const message = await anthropic.messages.create({
  model: 'claude-3-opus-20240229',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Analyze this document...' }],
});

Option B: Manual tracking

For other providers or custom implementations:

import { Orbit } from '@with-orbit/sdk';

const orbit = new Orbit({ apiKey: 'orb_live_xxx' });

// Track a successful request
await orbit.track({
  model: 'gpt-4o',
  input_tokens: 150,
  output_tokens: 50,
  latency_ms: 1234,
  feature: 'summarization',
  environment: 'production',
});

// Track an error
await orbit.trackError('gpt-4o', 'rate_limit_exceeded', 'Rate limit exceeded', {
  feature: 'chat-assistant',
  input_tokens: 150,
});

Configuration

const orbit = new Orbit({
  // Required
  apiKey: 'orb_live_xxx',

  // Optional
  baseUrl: 'https://app.withorbit.io/api/v1', // Custom API endpoint
  defaultFeature: 'my-app',                   // Default feature name
  defaultEnvironment: 'production',            // 'production' | 'staging' | 'development'
  debug: false,                                // Enable debug logging

  // Batching (for high-volume applications)
  batchEvents: true,       // Batch events before sending
  batchSize: 10,           // Max events per batch
  batchInterval: 5000,     // Max ms before sending batch

  // Reliability
  retry: true,             // Retry failed requests
  maxRetries: 3,           // Max retry attempts
});

Event Properties

| Property | Type | Required | Description | |----------|------|----------|-------------| | model | string | Yes | Model name (e.g., 'gpt-4o', 'claude-3-opus') | | input_tokens | number | Yes | Number of input tokens | | output_tokens | number | Yes | Number of output tokens | | provider | string | No | Provider name (auto-detected if not provided) | | latency_ms | number | No | Request latency in milliseconds | | feature | string | No | Feature name for attribution | | environment | string | No | Environment ('production', 'staging', 'development') | | status | string | No | Request status ('success', 'error', 'timeout') | | error_type | string | No | Error type if status is 'error' | | error_message | string | No | Error message if status is 'error' | | user_id | string | No | Your application's user ID | | session_id | string | No | Session ID for grouping requests | | request_id | string | No | Unique request ID for tracing | | metadata | object | No | Additional key-value metadata |

Feature Attribution

Features are Orbit's killer feature - they let you see exactly which parts of your application are consuming AI resources:

// Track different features
await orbit.track({
  model: 'gpt-4o',
  input_tokens: 100,
  output_tokens: 50,
  feature: 'chat-assistant',  // <-- Attribute to chat feature
});

await orbit.track({
  model: 'gpt-4o',
  input_tokens: 500,
  output_tokens: 200,
  feature: 'document-analysis',  // <-- Attribute to doc analysis
});

Then in the Orbit dashboard, you'll see:

  • Cost breakdown by feature
  • Request volume by feature
  • Error rates by feature
  • And more!

Environments

Track usage across different environments:

const orbit = new Orbit({
  apiKey: 'orb_live_xxx',
  defaultEnvironment: process.env.NODE_ENV === 'production' ? 'production' : 'development',
});

Graceful Shutdown

For serverless or short-lived processes, flush events before exit:

// Before your process exits
await orbit.shutdown();

TypeScript Support

Full TypeScript support with exported types:

import { Orbit, OrbitEvent, OrbitConfig } from '@with-orbit/sdk';

const config: OrbitConfig = {
  apiKey: 'orb_live_xxx',
};

const event: OrbitEvent = {
  model: 'gpt-4o',
  input_tokens: 100,
  output_tokens: 50,
};

License

MIT