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

@tokenlay/sdk

v0.1.0

Published

JavaScript SDK for Tokenlay - AI operations platform with intelligent routing and cost control

Readme

@tokenlay/sdk – JavaScript Client

A lightweight OpenAI-compatible SDK for routing your LLM calls through the Tokenlay proxy — enabling real-time usage tracking, spend control, and per-user limits.

Tokenlay helps developers stay profitable by enforcing usage policies and providing billing visibility — without needing to rebuild infrastructure.


Installation

npm install @tokenlay/sdk openai

openai is a peer dependency.


Quickstart

import { TokenlayOpenAI } from "@tokenlay/sdk";
import OpenAI from "openai";

const openai = new TokenlayOpenAI({
  providerApiKey: process.env.PROVIDER_API_KEY,
  providerApiBase: process.env.PROVIDER_API_BASE,
  tokenlayKey: process.env.TOKENLAY_KEY,
});

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

console.log(response.choices[0].message.content);

Common Providers & Example Models

Tokenlay supports most major LLM providers out of the box, powered by LiteLLM.
Here are some common providers and example model names:

| Provider | providerApiBase | Example Models | | ----------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------- | | OpenAI | https://api.openai.com/v1 | gpt-4o, o4-mini, o3 | | Anthropic | https://api.anthropic.com/v1 | claude-opus-4, claude-sonnet-4 | | Mistral | https://api.mistral.ai/v1 | mistral-large-24.11, codestral-25.01 | | OpenRouter | https://openrouter.ai/v1 | mistralai/mistral-7b-instruct | | Together AI | https://api.together.xyz/v1 | togethercomputer/llama-2-13b-chat |

For a comprehensive list of models and providers, see: → List


Per-User Tracking & Custom Metadata

To enable per-user usage tracking, Tokenlay supports passing a user identifier — or any custom fields — via the extraHeaders option.

This is entirely optional, but highly recommended for applying user-level enforcement and attribution.

How to Pass a User UUID

const openai = new TokenlayOpenAI({
  providerApiKey: process.env.PROVIDER_API_KEY,
  providerApiBase: process.env.PROVIDER_API_BASE,
  tokenlayKey: process.env.TOKENLAY_KEY,
  extraHeaders: {
    user: "user_abc123" // Your internal user ID
  }
});

You can also set extraHeaders dynamically per request for variable context. → Docs

Example: Custom Metadata

You can add any fields relevant to your system:

extraHeaders: {
  user: "user_abc123",
  org: "org_456xyz",
  plan: "pro",
  project: "chatbot_xyz",
  feature: "autocomplete"
}

These headers are forwarded to Tokenlay and become visible in logs, dashboards, and usage enforcement.


Getting Your Tokenlay Key

Use of this SDK requires a Tokenlay API key, which links requests to your account and enables tracking, enforcement, and billing visibility.

You can generate a key from the Tokenlay Dashboardabsolutely free.

Once configured, your key powers:

  • Live dashboards to monitor real-time token usage and spending
  • Flexible policies including per-user limits, monthly caps, and org-wide rules
  • Granular enforcement with attribution by user, org, project, or pricing tier
  • Smart fallbacks like model shifting or throttling — keeping users happy without compromising margins

Tokenlay helps developers stay profitable by stopping overuse and runaway spend — no need to rebuild metering, limits, or dashboards yourself.

Documentation

Want to go deeper? → Explore the full docs for advanced usage and best practices


License

MIT