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

metrix-ai

v0.1.0

Published

LLM Cost Intelligence SDK — track, optimize, and control your AI spend

Readme

metrix.ai Node.js SDK

LLM Cost Intelligence SDK — track, optimize, and control your AI spend across OpenAI, Anthropic, and Gemini.

Install

npm install metrix-ai

Quickstart

import { MetrixClient } from "metrix-ai";

const client = new MetrixClient({
  apiKey: "your-metrix-token",
  providerApiKey: "your-anthropic-key",
  project: "my-project",
  debug: true,
});

const response = await client.chat({
  provider: "anthropic",
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Hello from metrix.ai!" }],
});

console.log(response.content);
console.log(`Tokens used: ${response.totalTokens}`);
console.log(`Latency: ${response.latencyMs}ms`);

Environment Variables

export METRIX_API_KEY=your-metrix-token
export METRIX_PROVIDER_API_KEY=your-anthropic-key
export METRIX_PROJECT=my-project
export METRIX_AUTO_ROUTE=true
export METRIX_DEBUG=true

Then just:

import { MetrixClient } from "metrix-ai";
const client = new MetrixClient();

Smart Routing

const client = new MetrixClient({
  apiKey: "...",
  providerApiKey: "...",
  autoRoute: true,
});

const response = await client.chat({
  provider: "anthropic",
  model: "claude-opus-4-6",
  messages: [{ role: "user", content: "What is 2+2?" }],
});

if (response.routed) {
  console.log(`Routed from ${response.originalModel} → ${response.model}`);
}

Project Attribution

const response = await client.chat({
  provider: "anthropic",
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Summarize this..." }],
  project: "customer-support",
  tags: { env: "prod", feature: "summarization" },
});

Supported Providers

| Provider | Models | |-----------|--------| | anthropic | claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5 | | openai | gpt-4o, gpt-4o-mini, gpt-4-turbo | | gemini | gemini-1.5-pro, gemini-1.5-flash |

Error Handling

import {
  MetrixClient,
  MetrixAuthError,
  ProviderRateLimitError,
  ProviderTimeoutError,
  MetrixConnectionError,
  UnsupportedProviderError,
} from "metrix-ai";

try {
  const response = await client.chat({ ... });
} catch (err) {
  if (err instanceof MetrixAuthError) console.log("Invalid token");
  if (err instanceof ProviderRateLimitError) console.log("Rate limited");
  if (err instanceof ProviderTimeoutError) console.log("Timed out");
  if (err instanceof MetrixConnectionError) console.log("Proxy unreachable");
  if (err instanceof UnsupportedProviderError) console.log(err.message);
}

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | env | metrix.ai JWT token | | providerApiKey | string | env | LLM provider API key | | project | string | undefined | Project slug | | autoRoute | boolean | false | Enable smart routing | | tags | object | undefined | Attribution tags | | timeout | number | 60000 | Timeout in ms | | maxRetries | number | 2 | Retry attempts | | debug | boolean | false | Colored debug output | | baseUrl | string | localhost | Proxy base URL |

License

MIT — Ahmad Sharique