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

stillrunning-vercel-ai-sdk

v0.1.0

Published

One-line monitoring for the Vercel AI SDK. Auto-pings StillRunning on every generateText / streamText / generateObject run with duration, tokens, cost, model, and tool-call counts.

Readme

stillrunning-vercel-ai-sdk

Monitoring for the Vercel AI SDK, in one line.

Wrap your generateText / streamText / generateObject calls and every run reports its duration, token usage, estimated cost, model, and tool-call count to a StillRunning workflow. Get alerted the moment an agent fails, runs too long, or costs too much, without writing any ping plumbing.

npm install stillrunning-vercel-ai-sdk

30-second quickstart

  1. Create a workflow at stillrunning.ai/app/new and copy its ping token.

  2. Set it as an env var:

    STILLRUNNING_TOKEN=your_token_here
  3. Swap your ai import for the StillRunning client:

    import { stillrunning } from 'stillrunning-vercel-ai-sdk'
    import { openai } from '@ai-sdk/openai'
    
    const { generateText } = stillrunning() // reads STILLRUNNING_TOKEN
    
    const { text } = await generateText({
      model: openai('gpt-4o'),
      prompt: 'Summarize today’s standup notes.',
    })

That’s it. Every call now shows up in StillRunning with cost, tokens, and timing, and you get an alert if a run fails, stalls, or spikes in cost.

What gets captured

On each run the SDK sends a ping with:

| Field | Source | | ------------ | ----------------------------------------------------------------- | | durationMs | wall-clock time of the call | | tokensIn | result.totalUsage.inputTokens (aggregated across all steps) | | tokensOut | result.totalUsage.outputTokens | | costUsd | estimated from a built-in pricing table (override-able) | | model | result.response.modelId | | toolCalls | total tool calls across every step | | traceId | groups one logical run (auto-generated, or set via withTrace) | | metadata | { finishReason, steps } |

A failed call sends a fail ping with the error message, then rethrows the original error unchanged. Monitoring never alters your control flow, and a ping that fails to send never throws into your code.

Streaming

streamText is handled too. The success ping fires when the stream finishes, and your own onFinish / onError callbacks are preserved:

const { streamText } = stillrunning()

const result = streamText({
  model: openai('gpt-4o'),
  prompt: 'Write a haiku about uptime.',
  onFinish: ({ text }) => console.log('done:', text), // still called
})
for await (const chunk of result.textStream) process.stdout.write(chunk)

Grouping multi-step agent runs with withTrace

By default each call is its own run (one traceId). When an agent makes several model calls that are really one logical execution, wrap them so they share a trace, and StillRunning stitches them into a single outcome chain:

import { stillrunning, withTrace } from 'stillrunning-vercel-ai-sdk'

const sr = stillrunning()

await withTrace(async () => {
  await sr.generateText({ model, prompt: 'plan the task' })
  await sr.generateText({ model, prompt: 'execute step 1' })
  await sr.generateText({ model, prompt: 'execute step 2' })
}) // all three pings share one traceId

You can pass an explicit traceId / parentRunId for nested agents: withTrace(fn, { traceId, parentRunId }).

Cost estimation

Cost is estimated from token counts and a built-in pricing table covering current Claude, GPT, and Gemini models. It’s intentionally approximate, it powers relative cost-anomaly detection (a 5x spike is a 5x spike regardless of the exact rate) and a ballpark spend figure. For exact accounting:

// Full control:
const sr = stillrunning({
  computeCost: ({ model, inputTokens, outputTokens }) => myExactPricing(model, inputTokens, outputTokens),
})

// Or extend / override the built-in table:
import { registerModelPricing } from 'stillrunning-vercel-ai-sdk'
registerModelPricing([[/my-custom-model/, { input: 1.5, output: 6 }]]) // USD per 1M tokens

Unknown models simply send no cost rather than a wrong one.

Configuration

stillrunning({
  token,            // ping token; defaults to process.env.STILLRUNNING_TOKEN
  baseUrl,          // defaults to https://stillrunning.ai
  computeCost,      // (input) => number | undefined , override cost estimation
  awaitPing,        // default true; set false for lowest latency (fire-and-forget)
  pingTimeoutMs,    // default 3000
  onError,          // (err) => void , observe ping delivery failures
  fetch,            // custom fetch (testing / non-global-fetch runtimes)
})

By default the ping is awaited so it delivers reliably on serverless, adding the ping's round-trip (a single small POST, hard-bounded by pingTimeoutMs) to a non-streaming call's return. A slow or down StillRunning can therefore add up to pingTimeoutMs to a call but never hangs your agent; set awaitPing: false for zero added latency (fire-and-forget). For streamText, your own onFinish always runs before the ping, so streaming consumers are never gated on StillRunning.

Requirements

  • Node 18+ (or any runtime with fetch and AsyncLocalStorage)
  • ai (Vercel AI SDK) v5 or later, as a peer dependency

License

MIT