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

pricetoken

v0.13.10

Published

Real-time LLM pricing data — typed client, cost calculator, and static pricing

Readme

pricetoken

Real-time LLM pricing data. Typed client, offline cost calculator, and static pricing for every major provider.

Install

npm install pricetoken

Quick start

import { PriceTokenClient } from 'pricetoken';

const pt = new PriceTokenClient();

// Get all model pricing
const models = await pt.getPricing();

// Filter by provider
const anthropic = await pt.getPricing({ provider: 'anthropic' });

// Get a single model
const opus = await pt.getModel('claude-opus-4-6');

// Find the cheapest model
const cheapest = await pt.getCheapest();

// Compare models side by side
const compared = await pt.compare(['gpt-4o', 'claude-sonnet-4-6']);

// Price history (last 30 days)
const history = await pt.getHistory({ days: 30 });

// List providers
const providers = await pt.getProviders();

Authentication

Free tier: 30 requests/hour (no key required).

For higher limits, pass an API key:

const pt = new PriceTokenClient({ apiKey: 'pt_...' });

Offline cost calculation

Calculate costs without any API calls using bundled static pricing:

import { calculateModelCost } from 'pricetoken';

const cost = calculateModelCost('gpt-4o', 1000, 500);
// { modelId: 'gpt-4o', inputTokens: 1000, outputTokens: 500,
//   inputCost: 0.0025, outputCost: 0.0075, totalCost: 0.01 }

Or use your own pricing data:

import { calculateCost } from 'pricetoken';

const cost = calculateCost('my-model', 2.50, 10.00, 1000, 500);

Static pricing data

Access bundled pricing without network calls:

import { STATIC_PRICING } from 'pricetoken';

console.log(STATIC_PRICING.length); // 21 models

Note: Static data reflects prices at the time the package was published and does not auto-update. For the latest prices, use PriceTokenClient to fetch live data from the API.

API

PriceTokenClient

| Method | Returns | Description | |--------|---------|-------------| | getPricing(opts?) | ModelPricing[] | All models. Filter by provider, currency. | | getModel(modelId, opts?) | ModelPricing | Single model by ID. | | getCheapest(opts?) | ModelPricing | Cheapest model. Filter by provider. | | compare(modelIds, opts?) | ModelPricing[] | Compare specific models. | | getHistory(opts?) | ModelHistory[] | Price history. Filter by days, modelId, provider. | | getProviders() | ProviderSummary[] | All providers with model counts. |

Options

new PriceTokenClient({
  baseUrl: 'https://pricetoken.ai', // default
  apiKey: 'pt_...',                  // optional
});

Types

All types are exported:

import type {
  ModelPricing,
  PriceHistoryPoint,
  ModelHistory,
  ProviderSummary,
  CostEstimate,
  PriceTokenResponse,
  PriceTokenError,
} from 'pricetoken';

Disclaimer

Pricing data is provided on a best-effort basis and may be inaccurate, incomplete, or outdated. LLM providers change prices without notice, and our scraping pipeline may not capture every change immediately.

This data is for informational purposes only. Do not use it as the sole basis for financial decisions. Always verify pricing directly with the provider before committing to spend.

If you get a bill you weren't expecting, that's between you and your provider — not us. See the MIT License under which this project is distributed (specifically the "AS IS" and "NO WARRANTY" clauses).

Found incorrect pricing? Open an issue.

License

MIT