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

@basisoasis/llm-intel

v1.0.22

Published

Source model capabilities and pricing from OpenRouter for cost-aware development without hardcoded data tables

Downloads

3,323

Readme

llm-intel

Model intelligence for every LLM.

llm-intel sources model metadata and pricing from OpenRouter, so you can look up capabilities and calculate token costs without maintaining your own data tables.

Features

  • Look up any model's capabilities, context window, and pricing by ID
  • Calculate token costs with exact precision (powered by bignumber.js)
  • Two purpose-built APIs: a server client (fetches from OpenRouter) and a browser client (reads pre-fetched JSON)
  • Three-tier caching: memory -> disk -> network
  • Full TypeScript support with generated ModelId types

View Demo →

Installation

# npm
npm install @basisoasis/llm-intel

# pnpm
pnpm add @basisoasis/llm-intel

# yarn
yarn add @basisoasis/llm-intel

# bun
bun add @basisoasis/llm-intel

Usage

Server (LLMIntel)

Use this in Node.js / server-side environments. It fetches model data from OpenRouter, with disk and memory caching built in.

import { LLMIntel } from "@basisoasis/llm-intel";

// Instantiate a provider client
const client = await LLMIntel.create({ provider: 'openrouter' });

// Resolve a model by ID
const model = await client.getModel(
  'anthropic/claude-4.6-sonnet-20260217'
);

if (!model) throw new Error('Model not found!');

const cost = client.calculateCost(model, {
  inputTokens: 20_000,
  outputTokens: 1700,
});

console.log(client.formatCostResult(cost));
/* {
  inputCost: "$0.06",
  outputCost: "$0.03",
  cacheReadCost: null,
  cacheWriteCost: null,
  imageCost: null,
  requestCost: null,
  totalCost: "$0.09",
  currency: "USD",
  warnings: [],
} */

Standalone function

For one-off lookups without instantiating a client:

import { getModelInfo } from "@basisoasis/llm-intel";

const result = await getModelInfo("anthropic/claude-3-5-sonnet", {
  provider: "openrouter",
  apiKey: process.env.OPENROUTER_API_KEY,
});

Browser / SPA (LLMIntelClient)

Use this when you already have the model JSON (e.g. fetched server-side and passed to a SPA, or bundled at build time). No API key required.

import { LLMIntelClient } from "@basisoasis/llm-intel/client";

// Hydrate from a URL your server exposes
const client = new LLMIntelClient({
  models: "/api/models", // returns ModelsResult JSON
  cacheTtl: 5 * 60 * 1000, // 5 minutes
});

// Or hydrate statically from a pre-loaded array
const client = new LLMIntelClient({ models: modelDataArray });

const model = await client.getModel("google/gemini-2.5-pro");
if (!model) throw new Error('Model not found!');

const cost = client.calculateCost(model, {
  inputTokens: 2000,
  outputTokens: 800,
});

console.log(client.formatCost(cost.inputCost));  // $0.0025
console.log(client.formatCost(cost.outputCost)); // $0.008
console.log(client.formatCost(cost.totalCost));  // $0.01

API Reference

LLMIntel (server)

| Method | Description | | ------------------------------------------------ | -------------------------------------------------------------- | | LLMIntel.create(opts) | Creates a validated client instance. Validates config upfront. | | client.getModels() | Returns all available models (ModelsResult). | | client.getModel(modelId) | Returns a single model by ID, or null if not found. | | client.calculateCost(model, tokens, currency?) | Calculates prompt/completion/total cost. | | client.formatCost(amount, currency?) | Formats a BigNumber as a currency string (e.g. "$5.12"). | | client.formatCostResult(result) | Formats all line items in a CostResult to strings. |

LLMIntelClient (browser)

Same getModel, getModels, calculateCost, formatCost, and formatCostResult methods. Takes either a URL or a pre-loaded ModelData[] array.

getModelInfo(modelId, opts) (standalone)

Fetches a single model without creating a client. Useful for serverless functions or scripts.

Caching

LLMIntel uses a three-tier cache:

  1. Memory: fastest; per-instance, invalidated by TTL
  2. Disk: survives process restarts
  3. Network: fetches fresh data from OpenRouter

Configure the TTL via cacheTtl in milliseconds (default: 86_400_000 — 24 hours).

LLMIntelClient uses memory caching only (no disk access in the browser).

Configuration

All options are optional — the library falls back to environment variables and then built-in defaults.

LLMIntel.create({
  provider: "openrouter",
  openRouterApiKey: process.env.LLM_INTEL_OPEN_ROUTER_API_KEY,
  cacheTtl: 86_400_000,
  cacheDir: ".cache",
});

| Option | Env var | Default | Description | | ------------------ | ------------------------------- | ----------------------- | ----------------------------------------------------------------------- | | provider | LLM_INTEL_PROVIDER | "openrouter" | Data source to use. See Providers. | | openRouterApiKey | LLM_INTEL_OPEN_ROUTER_API_KEY | — | Your OpenRouter API key. Required when using the openrouter provider. | | cacheTtl | LLM_INTEL_CACHE_TTL | 86_400_000 (24 hours) | How long cached model data is considered fresh, in milliseconds. | | cacheDir | LLM_INTEL_CACHE_DIR | {cwd}/.cache | Directory used for disk caching. |

Providers

Currently, OpenRouter is the only supported provider. The library has been designed with a provider abstraction layer, so support for additional data sources can be added in the future without breaking changes to the public API.

| Provider | Status | | ---------- | ------------ | | OpenRouter | ✅ Supported | | Others | 🗓 Planned |

License

MIT