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

@komplexai/halu

v0.1.0

Published

JavaScript/TypeScript client for Komplex AI — a hallucination detector for LLM output. Score any response for hallucination risk in one call.

Readme

@komplexai/halu

JavaScript/TypeScript client for Komplex AI — a hallucination detector for LLM output. Score any AI response for hallucination risk in one call. Works in Node 18+ and modern browsers (zero dependencies — uses native fetch).

npm install @komplexai/halu

Quick start

import { detect } from "@komplexai/halu"; // set HALU_API_KEY in your env

const result = await detect("The Eiffel Tower was built in 1789 by Napoleon Bonaparte.");
console.log(result.pHallucination); // 0.87 — likely a hallucination
console.log(result.flag);           // true
console.log(result.topRegime);      // "FABRICATED"

Get a free API key — no credit card.

First call slow? The detector scales to zero when idle, so the first request after a quiet period warms the model and can take ~10–30s. Later calls are fast. If a first call times out, retry, or give it more room: detect(text, { timeoutMs: 60000 }).

Authentication

detect() reads the API key from options.apiKey, else the HALU_API_KEY environment variable. Keys are sent as Authorization: Bearer <key>.

await detect("...", {
  apiKey: "sk_...",
  baseUrl: "https://api.komplexai.io", // default
  timeoutMs: 30000,                    // default
});

HALU_BASE_URL and HALU_TIMEOUT_MS env vars override the defaults.

Browser note: don't ship a real API key in client-side code — proxy through your own backend. Env-var key loading only applies in Node.

Gate output — detectOrThrow

import { detectOrThrow, HaluHallucinationFlagged } from "@komplexai/halu";

try {
  await detectOrThrow(llmResponse, { threshold: 0.5 });
  // safe to use llmResponse
} catch (e) {
  if (e instanceof HaluHallucinationFlagged) {
    // e.result has pHallucination, topRegime, etc.
    answer = "I'm not sure — please verify with an expert.";
  }
}

What detect() returns

| Field | Type | Description | |---|---|---| | pHallucination | number | Calibrated probability (0–1). | | flag | boolean | True when the server's threshold is exceeded. | | topRegime | string | Most likely regime (NORMAL, FABRICATED, CF_AUTH, NEAR_FALSE, FALSE_REFUSAL, Other). | | regimeScores | RegimeScore[] | All regime probabilities. | | requestId | string | Server request ID for log correlation. | | latencyMs | number | Server-side inference time. | | modelVersion / calibratorVersion | string | Build identifiers. |

Errors

All errors extend HaluError and carry .requestId:

| Class | HTTP | When | |---|---|---| | HaluAuthError | 401 | Missing/invalid key | | HaluQuotaError | 402 | Quota exceeded (.quotaPeriod, .upgradeUrl) | | HaluRateLimitError | 429 | Rate limited (.retryAfter) | | HaluInputError | 400 | Bad request (.errorCode) | | HaluServerError | 5xx | Upstream/handler failure (.statusCode) | | HaluHallucinationFlagged | — | Thrown by detectOrThrow (.result) |

Scope & limits

English natural-language responses, up to 2,048 characters. Probabilistic signal, not a fact-checker. Free tier: 3,700 API units/month. See Performance for per-regime accuracy and the Guide for the full API.

License

Apache-2.0