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

@spendlil/sdk

v0.1.1

Published

SpendLil SDK — drop-in AI proxy wrapper for cost tracking, compliance, and rate limiting

Readme

SpendLil TypeScript SDK

Drop-in wrapper for OpenAI, Anthropic, Google, and Mistral that routes all AI calls through your SpendLil proxy — giving you cost tracking, compliance controls, PII detection, rate limiting, and audit logs with zero code changes.

Install

npm install @spendlil/sdk

Quick start

import { SpendLil } from '@spendlil/sdk';

const sl = new SpendLil({
  agentId: 'your-agent-id',         // from SpendLil dashboard
  baseUrl: 'https://spendlil.yourco.com/api',
});

// ── OpenAI (drop-in replacement) ─────────────────────────
const openai = sl.openai({ apiKey: process.env.OPENAI_API_KEY! });

const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);
console.log(response._spendlil); // { tracked: true, model: 'gpt-4o', tier: 'frontier', ... }

// ── Anthropic (drop-in replacement) ──────────────────────
const anthropic = sl.anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! });

const msg = await anthropic.messages.create({
  model: 'claude-sonnet-4-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Summarise this...' }],
});

console.log(msg.content[0].text);

// ── Auto-routing (SpendLil picks the best model) ─────────
const autoRes = await openai.chat.completions.autoCreate({
  messages: [{ role: 'user', content: 'Write a haiku about TypeScript' }],
});

console.log(autoRes._spendlil?.model); // e.g. 'gpt-4o-mini' — SpendLil chose

// ── Streaming ─────────────────────────────────────────────
for await (const chunk of openai.chat.completions.createStream({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Count to 5' }],
  stream: true,
})) {
  const text = (chunk as any).choices?.[0]?.delta?.content ?? '';
  process.stdout.write(text);
}

// ── Session / context management ─────────────────────────
const sessionSl = sl.withSession('user-session-abc123');
const sessionOpenai = sessionSl.openai({ apiKey: process.env.OPENAI_API_KEY! });
// All requests with this client share context in SpendLil (STICKY/POOL mode)

SpendLil metadata

Every response includes _spendlil with proxy metadata:

| Field | Description | |-------|-------------| | tracked | Request was logged by SpendLil | | model | Model actually used (may differ from requested due to routing) | | provider | Provider used | | tier | economy / standard / frontier | | fallback | Whether a fallback model was used after a failure | | escalated | Whether the request was auto-escalated to a better model | | translated | Cross-provider format translation was applied | | sessionKey | Active session key (if context management enabled) | | contextMode | none / sticky / pool |

Error handling

import { SpendLilError } from '@spendlil/sdk';

try {
  await openai.chat.completions.create({ model: 'gpt-4o', messages: [] });
} catch (err) {
  if (err instanceof SpendLilError) {
    console.error(`HTTP ${err.status}: ${err.message}`);
    if (err.meta?.quotaExceeded) {
      console.error('Agent quota exceeded');
    }
  }
}

Batch / deferred processing

const response = await openai.chat.completions.create(
  { model: 'gpt-4o', messages: [...] },
  { priority: 'batch' },  // deferred to SpendLil batch queue
);
// Returns 202 with batch job ID