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

@reaatech/agent-budget-pricing

v0.1.1

Published

LLM pricing table management for agent-budget-controller

Readme

@reaatech/agent-budget-pricing

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

LLM pricing table management with LRU-cached lookups, model name normalization, and cost computation. Ships with built-in pricing for Anthropic, OpenAI, Google, and AWS Bedrock.

Installation

npm install @reaatech/agent-budget-pricing
# or
pnpm add @reaatech/agent-budget-pricing

Feature Overview

  • 4 providers built in — Anthropic (Claude), OpenAI (GPT/o-series), Google (Gemini), AWS Bedrock (multi-model)
  • Token cost computationcomputeCost(inputTokens, outputTokens, modelId) returns exact dollar cost, with optional cache read/write token accounting
  • Cost estimationestimateCost(modelId, estimatedInputTokens) for pre-flight budget checks
  • Model name normalizationModelNormalizer maps provider aliases to canonical model IDs
  • LRU cache with TTL — configurable cache TTL (default 1 hour) avoids repeated table lookups
  • Programmatic table loadingloadTable(provider, models) for custom or updated pricing
  • File-based overrides — load pricing from JSON files to override or extend built-in tables
  • Dual ESM/CJS output — works with import and require

Quick Start

import { PricingEngine } from '@reaatech/agent-budget-pricing';

const pricing = new PricingEngine({ cacheTtlMs: 3600_000 });

const cost = pricing.computeCost(500, 200, 'claude-sonnet-4', 'anthropic');
// → 0.0045  (500/1M × $3 + 200/1M × $15)

const estimate = pricing.estimateCost('claude-sonnet-4', 1000, 'anthropic');
// → 0.003   (1000/1M × $3 input, assuming 0.2 output ratio)

API Reference

PricingEngine

| Method | Description | | ---------------------------------------------------------------------- | ------------------------------------------------------------ | | lookup(modelId, provider?) | Look up PriceEntry for a model. Returns null if unknown. | | computeCost(inputTokens, outputTokens, modelId, provider?, options?) | Calculate dollar cost for actual token usage | | estimateCost(modelId, estimatedInputTokens, provider?, outputRatio?) | Estimate cost before the call (default output ratio: 0.2) | | loadTable(provider, models) | Load or replace pricing data for a provider | | clearCache() | Invalidate the LRU cache |

Constructor

new PricingEngine(options?: {
  cacheTtlMs?: number;    // default: 3600_000 (1 hour)
  normalize?: boolean;     // default: true — enable model name normalization
})

ModelNormalizer

import { ModelNormalizer } from '@reaatech/agent-budget-pricing';

const normalizer = new ModelNormalizer();
normalizer.registerAlias('anthropic', 'claude-3-opus', 'claude-opus-4-1');
normalizer.normalize('claude-3-opus', 'anthropic'); // → "claude-opus-4-1"

Built-in Pricing Tables

Anthropic

| Model | Input (per 1M tokens) | Output (per 1M tokens) | | ---------------- | --------------------- | ---------------------- | | Claude Opus 4-1 | $15.00 | $75.00 | | Claude Sonnet 4 | $3.00 | $15.00 | | Claude Haiku 3.5 | $0.25 | $1.25 |

OpenAI

| Model | Input (per 1M tokens) | Output (per 1M tokens) | | ----------- | --------------------- | ---------------------- | | GPT-4 | $30.00 | $60.00 | | GPT-4 Turbo | $10.00 | $30.00 | | GPT-4 Mini | $0.15 | $0.60 | | o1 | $15.00 | $60.00 | | o3 | $15.00 | $60.00 |

Google Gemini

| Model | Input (per 1M tokens) | Output (per 1M tokens) | | ---------------- | --------------------- | ---------------------- | | Gemini 2.0 Flash | $0.10 | $0.40 | | Gemini 2.0 Pro | $1.25 | $5.00 |

AWS Bedrock

| Model | Input (per 1M tokens) | Output (per 1M tokens) | | --------------- | --------------------- | ---------------------- | | Claude 3 Sonnet | $3.00 | $15.00 | | Claude 3 Haiku | $0.25 | $1.25 | | Llama 3 70B | $0.50 | $0.70 | | Mistral Large | $4.00 | $12.00 |

Usage Patterns

Custom Pricing Tables

import { PricingEngine } from '@reaatech/agent-budget-pricing';

const pricing = new PricingEngine();
pricing.loadTable('my-provider', {
  'my-model-v1': {
    inputPricePerMillion: 1.5,
    outputPricePerMillion: 5.0,
    cacheReadPricePerMillion: 0.15,
    cacheWritePricePerMillion: 1.875,
  },
  'my-model-v2': { inputPricePerMillion: 2.0, outputPricePerMillion: 8.0 },
});

const cost = pricing.computeCost(1000, 500, 'my-model-v1', 'my-provider', {
  cacheReadTokens: 250,
  cacheWriteTokens: 100,
});

Integration with Budget Check

import { PricingEngine } from '@reaatech/agent-budget-pricing';
import { BudgetController } from '@reaatech/agent-budget-engine';

const pricing = new PricingEngine();
const controller = new BudgetController({ spendTracker, pricing });

// BudgetController uses pricing.estimateCost() for pre-flight checks
const result = await controller.check({
  scopeType: BudgetScope.User,
  scopeKey: 'user-42',
  estimatedCost: pricing.estimateCost('claude-opus-4-1', 2000, 'anthropic'),
  modelId: 'claude-opus-4-1',
});

Related Packages

License

MIT