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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@stripe/ai-sdk

v0.1.1

Published

Stripe AI SDK - Provider and metering utilities for Vercel AI SDK

Readme

Stripe AI SDK - Provider and metering utilities for Vercel AI SDK

The Stripe AI SDK provides comprehensive tools for integrating AI models with Stripe's billing infrastructure. This unified package includes both a custom Vercel AI SDK provider and metering utilities for tracking token usage across any AI SDK provider.

Private preview access required

The Stripe AI SDK is currently only available to organizations participating in the Billing for LLM Tokens Private Preview. If you do not have access and would like to request it, please visit:

Request Access to Billing for LLM Tokens Private Preview

Overview

This package contains two main components:

Provider (@stripe/ai-sdk/provider)

A custom Vercel AI SDK provider that routes requests through Stripe's LLM proxy at llm.stripe.com, enabling automatic usage tracking and billing integration.

Key Features:

  • Unified API: Access OpenAI, Google Gemini, and Anthropic Claude through a single interface
  • Automatic tracking: Token usage is automatically reported to Stripe
  • Built-in billing: Seamlessly integrate AI costs into your Stripe billing workflow
  • Customer attribution: Automatically attribute usage to specific customers

Quick Start:

import { createStripe } from '@stripe/ai-sdk/provider';
import { generateText } from 'ai';

const stripeLLM = createStripe({
  apiKey: process.env.STRIPE_API_KEY,
  customerId: 'cus_xxxxx',
});

const { text } = await generateText({
  model: stripe('openai/gpt-5'),
  prompt: 'What are the three primary colors?',
});

→ Full Provider Documentation

Meter (@stripe/ai-sdk/meter)

A wrapper utility that adds billing tracking to any Vercel AI SDK language model, allowing you to use your preferred provider while still tracking usage in Stripe.

Key Features:

  • Universal Compatibility: Works with any AI SDK v2 provider
  • Non-Intrusive: Preserves all original model functionality
  • Fire-and-Forget: Billing events are sent asynchronously
  • Automatic Metering: Token consumption is automatically tracked
  • Customer Attribution: Attribute usage to specific customers

Quick Start:

import { meteredModel } from '@stripe/ai-sdk/meter';
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';

const model = meteredModel(
  openai('gpt-4o-mini'),
  process.env.STRIPE_API_KEY,
  'cus_xxxxx'
);

const { text } = await generateText({
  model,
  prompt: 'What are the three primary colors?',
});

→ Full Meter Documentation

Installation

npm install @stripe/ai-sdk

Which should I use?

Use the Provider when:

  • You want a unified interface to multiple AI providers
  • You prefer routing through Stripe's LLM proxy
  • You want automatic usage tracking without any wrapper code
  • You're building a new application

Use the Meter when:

  • You need to use specific provider features or configurations
  • You want to keep your existing provider setup
  • You need direct access to the native provider APIs
  • You're integrating into an existing codebase

Usage examples

Provider example

import { createStripe } from '@stripe/ai-sdk/provider';
import { streamText } from 'ai';

const stripeLLM = createStripe({
  apiKey: process.env.STRIPE_API_KEY,
  customerId: 'cus_xxxxx',
});

// Works with any supported model
const result = await streamText({
  model: stripeLLM('anthropic/claude-sonnet-4'),
  prompt: 'Write a short story about AI.',
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

Meter example

import { meteredModel } from '@stripe/ai-sdk/meter';
import { anthropic } from '@ai-sdk/anthropic';
import { streamText } from 'ai';

const model = meteredModel(
  anthropic('claude-3-5-sonnet-20241022'),
  process.env.STRIPE_API_KEY,
  'cus_xxxxx'
);

const result = await streamText({
  model,
  prompt: 'Write a short story about AI.',
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

Supported models

Provider models

The provider supports models from:

  • OpenAI: GPT-5, GPT-4.1, o3, o1, and more
  • Google: Gemini 2.5 Pro, Gemini 2.5 Flash, and more
  • Anthropic: Claude Opus 4, Claude Sonnet 4, Claude Haiku, and more

Meter compatibility

The meter works with any AI SDK v2 provider, including:

  • OpenAI (@ai-sdk/openai)
  • Anthropic (@ai-sdk/anthropic)
  • Google Gemini (@ai-sdk/google)
  • Azure OpenAI
  • Amazon Bedrock
  • And any custom v2 provider

Token usage tracking

Both components automatically report token usage to Stripe meter events:

{
  event_name: 'token-billing-tokens',
  payload: {
    stripe_customer_id: 'cus_xxxxx',
    value: '100',
    model: 'openai/gpt-4o-mini',
    token_type: 'input'
  }
}

Documentation

Examples

License

MIT