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

llm-cost-attr

v0.3.1

Published

FinOps cost attribution and optimization tool for LLM API usage. Scans codebases for LLM calls, estimates costs, recommends optimizations.

Readme

llm-cost-attr

FinOps cost attribution tool for LLM API usage. Scans your codebase, finds every LLM API call, estimates costs, and recommends optimizations.

Think of it as a cost linter for AI spend.

Install

npx llm-cost-attr scan .

Or install globally:

npm install -g llm-cost-attr
llm-cost-attr scan .

What it does

  1. Scans your codebase for LLM API calls across 5 providers
  2. Estimates monthly costs based on current model pricing
  3. Detects loops, caching patterns, and batch opportunities
  4. Recommends optimizations (model downgrades, caching, batching)

Supported Providers

| Provider | Detection Pattern | |----------|------------------| | OpenAI | openai.chat.completions.create(), openai.embeddings.create() | | Anthropic | client.messages.create() | | Google GenAI | model.generateContent(), model.embedContent() | | LangChain | ChatGoogleGenerativeAI, ChatOpenAI, ChatAnthropic, .invoke(), .ainvoke() | | Claude CLI | claude -p subprocess calls |

Works with both TypeScript/JavaScript and Python codebases.

Usage

Scan a repository

llm-cost-attr scan /path/to/repo

Set monthly invocation volume

llm-cost-attr scan /path/to/repo --volume 10000

Output formats

# Terminal (default)
llm-cost-attr scan /path/to/repo

# JSON (for CI pipelines)
llm-cost-attr scan /path/to/repo -f json -o report.json

# HTML dashboard
llm-cost-attr scan /path/to/repo -f html -o report.html

Compare multiple repos

llm-cost-attr compare /repo1 /repo2 /repo3

View pricing

llm-cost-attr pricing

Example Output

  LLM Cost Attribution Report
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Scanned: 193 files | Found: 5 LLM call sites
  Estimated monthly cost: $9.07 @ 1K invocations/month

┌──────────────────────────┬───────────┬──────────────────┬──────────┬──────┬──────────┐
│ File                     │ Provider  │ Model            │ $/call   │ Loop │ $/month  │
├──────────────────────────┼───────────┼──────────────────┼──────────┼──────┼──────────┤
│ src/aggregation.ts:232   │ anthropic │ claude-haiku-4-5 │ $0.0016  │ 5x   │ $8.00    │
│ src/llm-scorer.ts:178    │ anthropic │ claude-haiku-4-5 │ $0.0010  │ 5x   │ $5.00    │
│ src/llm-scorer.ts:163    │ google    │ gemini-2.0-flash │ $0.0001  │ 5x   │ $0.31    │
└──────────────────────────┴───────────┴──────────────────┴──────────┴──────┴──────────┘

  Optimization Opportunities:
  📦  src/aggregation.ts:232
      5 sequential calls in a loop. Consider batching or parallel execution.

How it works

Static analysis — no runtime proxy, no API keys needed. The tool:

  1. Walks your codebase (respects .gitignore)
  2. Detects SDK imports (OpenAI, Anthropic, Google GenAI, LangChain)
  3. Finds API call sites using regex + heuristic analysis
  4. Extracts model names, max_tokens, prompt sizes
  5. Detects loops (including cross-function call chains)
  6. Checks for existing caching (Redis, in-memory)
  7. Calculates costs using current provider pricing
  8. Generates optimization recommendations

Pricing Data

Built-in pricing for all major models (updated March 2026):

  • Anthropic: Opus 4 ($5/$25), Sonnet 4 ($3/$15), Haiku 4.5 ($0.25/$1.25)
  • OpenAI: GPT-4o ($2.50/$10), GPT-4o-mini ($0.15/$0.60), o1/o3
  • Google: Gemini 2.0 Flash ($0.10/$0.40), Gemini 2.0 Pro ($1.25/$5)

Per 1M tokens (input/output). Run llm-cost-attr pricing for the full list.

License

MIT