integrations/sdk/AIgateway Node SDK
TS

AIgateway Node SDK + AIgateway

Typed TypeScript SDK for async jobs, sub-accounts, evals, replays, and webhook verification.

For chat / embeddings / images / STT / TTS, use the official `openai` npm package with `baseURL: 'https://api.aigateway.sh/v1'`. The `aigateway` package wraps the aggregator-native surface OpenAI doesn't model — long-running jobs, sub-account billing, evals, replays, signed file URLs, and webhook signature verification.

AIgateway Node SDK homepage →
Setup

Three steps or fewer.

STEP 01

Install

Node 18+. Zero runtime dependencies. ESM + CJS exports. Distribution name on npm is aigateway-js (the bare 'aigateway' name was unavailable).

pnpm add aigateway-js   # or npm i aigateway-js
STEP 02

Submit an async video job

import { AIgateway } from "aigateway-js";

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

const job = await client.jobs.createVideo({
  prompt: "a sunset over mountains, cinematic",
  model: "runwayml/gen-4",
  duration: 5,
});

const done = await client.jobs.wait(job.id, { timeoutSeconds: 600 });
console.log(done.resultUrl);
STEP 03

Mint a sub-account

const acct = await client.subAccounts.create({
  name: "acme-corp",
  spendCapCents: 50_000,
  rateLimitRpm: 300,
  defaultTag: "acme",
});
console.log(acct.key);
STEP 04

Verify a webhook

import { verifyWebhook } from "aigateway-js";

const ok = verifyWebhook({
  secret: process.env.AIGATEWAY_WEBHOOK_SECRET!,
  body: rawBody,
  header: req.headers["x-gateway-signature"] as string,
});
Notes
  • Drop-in OpenAI calls belong in the `openai` package — set baseURL to AIgateway.
  • Working examples: github.com/aigateway-sh/examples · bug reports: github.com/aigateway-sh or support@aigateway.sh.
More integrations

Same key. Every other tool.