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

@idriszade/observe-vercel

v0.3.5

Published

Vercel AI SDK v7 nested-usage shim into pipeline-kit UsageAccumulator

Readme

@idriszade/observe-vercel

Vercel AI SDK v7 usage shim for pipeline-kit. Maps the nested inputTokenDetails.* / outputTokenDetails.* fields from a v7 LanguageModelUsage object into a UsageAccumulator using the OTel GenAI v1.37 key constants from @idriszade/observe. Non-additivity is preserved by construction — cache and reasoning sub-fields are recorded under their own keys and never summed into the parent totals.

Installation

pnpm add @idriszade/observe-vercel

Quick start

import { UsageAccumulator } from '@idriszade/core';
import { recordVercelUsage } from '@idriszade/observe-vercel';

// Typical v7 usage object from generateText / streamText.
const usage = {
  inputTokens: 500,
  outputTokens: 120,
  inputTokenDetails: {
    cacheReadTokens: 350,
    cacheWriteTokens: 0,
  },
  outputTokenDetails: {
    reasoningTokens: 40,
    textTokens: 80,
  },
};

const acc = new UsageAccumulator();
recordVercelUsage(usage, acc);

acc.get('gen_ai.usage.input_tokens');              // 500
acc.get('gen_ai.usage.input_tokens.cache_read');   // 350
acc.get('gen_ai.usage.output_tokens');             // 120
acc.get('gen_ai.usage.output_tokens.reasoning');   // 40

Fields that are undefined are silently skipped — no zero records are emitted.

Non-additivity

Cache and reasoning sub-fields are descriptive — they describe how the parent total was composed. Do not add them to the parent yourself.

See @idriszade/observeCache tokens are non-additive for the full explanation, reference, and code example.

v7 vs v6 migration

Vercel AI SDK v7 changed how sub-token counts are surfaced:

  • Top-level cachedInputTokens field removed.
  • Top-level reasoningTokens field removed.
  • Sub-counts now live exclusively under inputTokenDetails.cacheReadTokens, inputTokenDetails.cacheWriteTokens, outputTokenDetails.reasoningTokens, outputTokenDetails.textTokens.
  • inputTokens / outputTokens at the top level remain the inclusive totals — unchanged from v6.

recordVercelUsage accepts the v7 shape. If you are on v6 and passing a legacy object with top-level cachedInputTokens, those fields are not read; migrate to v7 inputTokenDetails first.

API

recordVercelUsage(usage, accumulator)

import type { VercelUsageV7 } from '@idriszade/observe-vercel';

function recordVercelUsage(usage: VercelUsageV7, accumulator: UsageAccumulator): void;

VercelUsageV7 mirrors the Vercel AI SDK v7 LanguageModelUsage shape with all fields optional to tolerate partial payloads from streaming responses.

License — MIT