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

@clarismd/sdk

v0.1.0

Published

Open-source AI gateway with PHI-aware governance — TypeScript client

Readme

Official TypeScript SDK for the ClarisMD governed-AI gateway for healthcare — PHI scanning, policy enforcement, audit logs, and OpenAI-shaped chat / embeddings, exposed through a single client.

  • Isomorphic. Native fetch only. Works in Node 18+, modern browsers, Cloudflare Workers, Deno, and Bun.
  • Zero runtime dependencies. ≤ 15 kB gzipped.
  • Strict TypeScript. Hand-written types ship today; OpenAPI codegen drops in once packages/openapi/v1.yaml stabilizes.

ClarisMD is healthcare infrastructure. The SDK does not transmit PHI on its own — it is the caller's responsibility to set the gateway policy headers (X-ClarisMD-Policy, X-ClarisMD-PHI-Action) appropriately. No real PHI on hosted demos — use synthetic data only.


Install

From npm (recommended):

npm install @clarismd/sdk
pnpm add @clarismd/sdk
yarn add @clarismd/sdk
bun add @clarismd/sdk

From the public GitHub repo (latest main, or pin to a tag/commit):

npm install github:amanjaiswal777/clarismd-node
npm install github:amanjaiswal777/clarismd-node#v0.1.0
npm install git+https://github.com/amanjaiswal777/clarismd-node.git#<commit-sha>

In a package.json:

{
  "dependencies": {
    "@clarismd/sdk": "github:amanjaiswal777/clarismd-node#v0.1.0"
  }
}

For local development:

git clone https://github.com/amanjaiswal777/clarismd-node.git
cd clarismd-node
npm install
npm run build && npm test

Requires Node.js 18+. Also runs unmodified on modern browsers, Cloudflare Workers, Deno, and Bun.

Quickstart

import { ClarisMD } from "@clarismd/sdk";

const client = new ClarisMD({ apiKey: process.env.CLARISMD_API_KEY });

const completion = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Summarize this discharge note." }],
});

console.log(completion.choices[0]?.message.content);

Migrating from the OpenAI SDK

Drop-in compatible — change two lines:

-import OpenAI from "openai";
-const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
+import { ClarisMD } from "@clarismd/sdk";
+const client = new ClarisMD({ apiKey: process.env.CLARISMD_API_KEY });

Self-hosting / private gateways

const client = new ClarisMD({
  apiKey: process.env.CLARISMD_API_KEY,
  baseURL: "https://gateway.internal.example.com/v1",
});

baseURL also resolves from CLARISMD_BASE_URL if you'd rather keep it out of code.

Verify the gateway is reachable (no API key required server-side):

const status = await client.health.check();
console.log(status.status, status.version); // "ok" "0.4.2"

Streaming

const stream = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Stream me a haiku." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta.content ?? "");
}

Mid-stream errors raise the same typed exceptions as synchronous calls — e.g. PHIPolicyViolationError when the gateway blocks an in-flight generation.

PHI scan

const result = await client.phi.scan(
  "Patient John Doe, DOB 1970-01-01, called about test results.",
);
console.log(result.detected, result.entities);

Audit logs

const page = await client.audit.list({
  startDate: new Date("2026-04-01"),
  endDate: new Date("2026-05-01"),
  phiDetected: true,
  limit: 100,
});

const blob = await client.audit.export({ format: "json" });
// In Node: await Bun.write("audit.json", blob); or fs.writeFileSync(...)

Compliance dashboard

const score = await client.compliance.score({ framework: "hipaa" });
const requirements = await client.compliance.requirements();
const evidence = await client.compliance.evidence(requirements[0]!.id);
await client.compliance.acknowledge(requirements[0]!.id, {
  status: "acknowledged",
  notes: "Reviewed Q2 2026",
});

Error handling

Every error inherits from ClarisMDError. Inspect instanceof for typed handling:

import {
  PHIPolicyViolationError,
  RateLimitError,
  APITimeoutError,
} from "@clarismd/sdk";

try {
  await client.chat.completions.create({ ... });
} catch (err) {
  if (err instanceof PHIPolicyViolationError) {
    // gateway blocked the request — fall back to a redaction flow
  } else if (err instanceof RateLimitError) {
    // 429 — backoff
  } else if (err instanceof APITimeoutError) {
    // network slow — retry or escalate
  } else {
    throw err;
  }
}

The SDK retries 429 / 5xx / network failures automatically with exponential backoff (500 ms, 1 s, 2 s) plus ±25% jitter; Retry-After is honored, capped at 60 s. Override per request:

await client.chat.completions.create({ ... }, { maxRetries: 0 });

AbortSignal

const controller = new AbortController();
setTimeout(() => controller.abort(), 30_000);

await client.chat.completions.create(
  { model: "gpt-4o-mini", messages: [...] },
  { signal: controller.signal },
);

ClarisMD-specific options

Per-request:

| Option | Header | Purpose | |---|---|---| | clarismdPolicy | X-ClarisMD-Policy | Override the gateway policy for this call | | clarismdPhiAction | X-ClarisMD-PHI-Action | One of block, redact, tokenize, alert | | idempotencyKey | Idempotency-Key | Pass false to disable; pass a string to set verbatim |

POSTs auto-generate Idempotency-Key: cmd-ts-${uuid} unless explicitly disabled.

Browser usage

Don't ship your gateway API key in browser-side JavaScript. Mint a short-lived scoped key on your backend and inject it into the page or exchange it via your own auth endpoint. The SDK runs in browsers; that doesn't mean a long-lived key is safe in one.

Cloudflare Workers

The SDK targets ES2020 + the standard fetch / Response / ReadableStream / crypto.randomUUID APIs available in Workers. See examples/cloudflare-worker.ts for an end-to-end fetch handler.

Examples

Runnable scripts live in examples/:

Contributing

Issues and PRs welcome — see CONTRIBUTING.md for the dev setup and PR conventions, and CODE_OF_CONDUCT.md for community expectations.

Security

Found a vulnerability? Please report it privately per SECURITY.md — do not open a public issue.

License

Apache-2.0 — see LICENSE and NOTICE.

The ClarisMD gateway and dashboard are licensed separately under AGPL-3.0; this SDK is intentionally permissive so any application can talk to a ClarisMD gateway regardless of its own license.