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

@theoven/ai

v0.6.1

Published

The infrastructure around AI SDK calls — SSE streaming, caching, token accounting and budgets

Readme

@theoven/ai

The infrastructure around an AI SDK call — streaming as SSE, caching, token accounting and budgets.

bun add @theoven/ai ai @ai-sdk/openai
import { openai } from '@ai-sdk/openai'
import { ai } from '@theoven/ai'

const app = createApp().use(ai({ model: openai('gpt-4o-mini') }))
// src/routes/chat.post.ts
export default (ctx) => ctx.ai.stream({ prompt: ctx.body.prompt })

What it does not do

It does not wrap the AI SDK's model layer. Providers, prompts, tools and structured output are the SDK's job, it does them well, and re-exporting them under our own names would age badly and teach a model nothing it already knows.

What is missing when you call the SDK straight from a route is everything around the call:

  • Streaming as SSEctx.ai.stream(...) returns a Response you can return.
  • Aborting on disconnect — a client hanging up cancels the provider call instead of leaving it generating and billing.
  • Not paying twice — identical calls are cached, and identical calls in flight at once share a single provider call.
  • Knowing what it cost — token counts and, when you supply prices, money.
  • Budgets — a request that has spent its allowance stops making calls.

Honest limits

  • A budget bounds how many calls a request makes, not how large one call is. Token counts are not known until the provider answers. Use maxOutputTokens for the per-call ceiling.
  • Caching makes generation deterministic for the TTL. Right for classification and embeddings; wrong for anything a user expects to vary. It is off unless configured.
  • Cost is undefined unless you supply pricing, and stays undefined when the provider reports no tokens. It is never silently 0.
  • Calls carrying tools are never cached — a tool holds a function, which cannot be keyed.
  • In-flight deduplication is per process, not across a cluster.

Full documentation: https://theoven.app/docs/bricks/ai/

MIT