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

aigateway-js

v0.1.3

Published

Official Node/TypeScript SDK for AIgateway — async jobs, sub-accounts, evals, replays, webhook verification. Install as aigateway-js; the bare 'aigateway' name is unavailable on npm.

Readme

aigateway-js (Node / TypeScript SDK)

Official Node SDK for AIgateway — one OpenAI-compatible API for every frontier and open-weight model, every modality.

Distribution name on npm is aigateway-js (the bare aigateway name was unavailable). All imports use the aigateway-js specifier.

For chat, embeddings, images, STT, TTS, moderation — just use the openai package with baseURL: 'https://api.aigateway.sh/v1'. AIgateway is drop-in.

This SDK covers the aggregator-native surface OpenAI doesn't model:

  • Async jobs — text-to-video, music, 3D with typed jobs.wait(id) helpers
  • Sub-accounts — one scoped key per end customer with spend caps
  • Evals — pick the winning model from a candidate set; alias as eval:<run_id>
  • Replays — re-run any past request against a new model and diff the output
  • Signed file URLs — share job results without handing out the gateway key
  • Webhook signature verification — HMAC-SHA256 with verifyWebhook()

Install

pnpm add aigateway-js     # or npm install aigateway-js / yarn add aigateway-js

Node 18+ required (for built-in fetch). ESM + CJS exports. Works in Workers, Edge runtimes, Deno, Bun.

Quickstart

import { AIgateway, verifyWebhook } from "aigateway-js";

const client = new AIgateway({ apiKey: process.env.AIGATEWAY_API_KEY! });

// 1. Submit a video job with a webhook.
const job = await client.jobs.createVideo({
  prompt: "a sunset over mountains, cinematic",
  model: "runwayml/gen-4",
  duration: 5,
  webhookUrl: "https://yourapp.com/hooks/aigateway",
});

// 2. Or poll until it's done:
const done = await client.jobs.wait(job.id, { timeoutSeconds: 600 });
console.log(done.resultUrl);

// 3. Mint a shareable signed URL:
const { url } = await client.files.signedUrl(job.id, "video.mp4", 3600);

Webhook verification

import { verifyWebhook } from "aigateway-js";

app.post("/hooks/aigateway", async (req, res) => {
  const raw = await req.text();
  const ok = verifyWebhook({
    secret: process.env.AIGATEWAY_WEBHOOK_SECRET!,
    body: raw,
    header: req.headers["x-gateway-signature"] as string,
  });
  if (!ok) return res.status(401).end();
  // ... handle the payload
});

Fetch your webhook secret with client.webhookSecret.get() or rotate it with client.webhookSecret.rotate().

Aggregator primitives

// Mint a scoped key for one of your customers.
const sub = await client.subAccounts.create({
  name: "customer-123",
  spendCapCents: 10_000,
  defaultTag: "customer-123",
});

// Run an eval across candidate models.
const run = await client.evals.create({
  name: "prod-summarize",
  candidateModels: ["anthropic/claude-opus-4.7", "moonshot/kimi-k2.6"],
  dataset: [{ input: "…", expected: "…" }],
  metric: "quality",
});
// Then route to the winner automatically by using `model: "eval:<run.id>"`.

// Replay a request on a new model.
const replay = await client.replays.run({
  sourceRequestId: "req_abc",
  targetModel: "anthropic/claude-opus-4.7",
});

Related packages

  • CLIaigateway-cli — installs the aig binary. Run aig init to walk through key + scaffold a starter file.
  • Python SDKaigateway-py — same surface, pip install aigateway-py.
  • MCP serverhttps://api.aigateway.sh/mcp (Streamable HTTP) and /mcp/sse (legacy). Inspect at /mcp/inspect.

Source, issues, examples

License

MIT © AIgateway