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

@useautumn/gateway

v0.0.1

Published

Autumn usage tracking adapters for AI SDKs and gateways (Vercel AI SDK, OpenRouter)

Readme

@useautumn/gateway

Autumn adapters for AI SDKs and gateways. Wrap your model or client once and every LLM call's token usage is tracked against the customer's AI credit balance — no manual trackTokens calls.

Autumn converts the token counts to a dollar cost server-side using live models.dev rates plus your configured markup, so pricing changes never require a client redeploy.

Install

npm install @useautumn/gateway
# or
bun add @useautumn/gateway

Authentication: pass an autumn client (from autumn-js), or set AUTUMN_API_KEY (or AUTUMN_SECRET_KEY) in the environment and omit it.

Vercel AI SDK

import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
import { withAutumn } from "@useautumn/gateway/ai-sdk";

const model = withAutumn({
  model: openai("gpt-4o"),
  customerId: "user_123",
});

const { text } = await generateText({ model, prompt: "Hello!" });
// usage tracked automatically — streaming too

The wrapped model is a drop-in LanguageModelV3. Usage is read from the response (or the stream's finish chunk) and reported as <provider>/<model> (e.g. anthropic/claude-sonnet-4-5). If your provider's name doesn't match its models.dev key, override it with providerId.

OpenRouter

import { OpenRouter } from "@openrouter/sdk";
import { withAutumn, trackingSettled } from "@useautumn/gateway/openrouter";

const client = withAutumn({
  openRouter: new OpenRouter({ apiKey: process.env.OPENROUTER_API_KEY }),
  customerId: "user_123",
});

const result = await client.chat.send({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});

The wrapper forces OpenRouter usage accounting on every request, tracks chat.send (streaming and non-streaming) and the responses API (including @openrouter/agent's callModel), and reports models as openrouter/<slug> using the response's resolved model — router aliases like openrouter/auto bill against the model that actually served the request. OpenRouter's own reported charge is attached to each event as openrouter_cost.

Streaming usage is tracked in the background; call await trackingSettled(client) before reading balances that must reflect calls just made. For consumption patterns the wrapper doesn't cover, trackOpenRouterUsage({ usage, model, customerId }) accepts both SDK camelCase and raw snake_case usage objects.

Options

Both adapters accept the shared tracking options:

| Option | Required | Description | |--------|----------|-------------| | customerId | Yes | Autumn customer ID to attribute usage to | | autumn | No | autumn-js client; falls back to AUTUMN_API_KEY env | | featureId | No | Target AI credit system feature (auto-detected if you have one) | | entityId | No | Entity for entity-scoped balances | | properties | No | Extra properties attached to each usage event |

Tracking failures are caught and logged — they never break your AI responses.

Docs