Skip to main content

Node SDK

The @adjudon/node package is the Node.js ingestion path. Zero runtime dependencies, dual CJS/ESM build, native TypeScript types, and Edge-Runtime compatible — the same module ships to Vercel Edge, Cloudflare Workers, and a long-running Express server without a fork.

Install

npm
npm install @adjudon/node
pnpm
pnpm add @adjudon/node
yarn
yarn add @adjudon/node

First call

TypeScript
import { Adjudon } from "@adjudon/node";

const adjudon = new Adjudon({
apiKey: process.env.ADJUDON_API_KEY!, // adj_agent_<48-hex>
agentId: "customer-support-bot",
});

const trace = await adjudon.trace({
inputContext: { prompt: "Can I get a refund for order #1234?" },
outputDecision: { action: "initiate_refund", confidence: 0.91 },
});

if (trace.status === "blocked") {
return "Sorry, I can't process this request right now.";
} else if (trace.status === "flagged") {
// Human reviewer will check — proceed with caution
}
JavaScript (CommonJS)
const { Adjudon } = require("@adjudon/node");

const adjudon = new Adjudon({
apiKey: process.env.ADJUDON_API_KEY,
agentId: "customer-support-bot",
});

const trace = await adjudon.trace({
inputContext: { prompt: "..." },
outputDecision: { action: "approve" },
});

trace.status is one of approved, flagged, blocked, or passthrough. passthrough is returned when failMode: "open" (the default) and Adjudon is unreachable — the agent is never blocked by infrastructure failure.

Versions

RuntimeSupportedNotes
Node.js 18Minimum supported (per engines field)
Node.js 20LTS
Node.js 22
Node.js 16 and earlierNot supported
BunThe package targets web standards (fetch); tested on Bun
Denonpm: imports work; tested
Vercel Edge / Cloudflare WorkersEdge-Runtime compatible — no Node-only crypto import

Current package version: 0.1.0 (Beta). Both CJS and ESM consumers get a build (require and import both work). TypeScript types ship in the package.

Configuration

Constructor fieldDefaultPurpose
apiKeyrequiredAgent API key (adj_agent_<48-hex>)
agentIdrequiredLogical agent identifier sent with every trace
baseUrlhttps://api.adjudon.com/api/v1Override only for staging
failMode"open"open returns passthrough on failure; closed throws
maxRetries3Retry attempts on 429 / 5xx
timeoutMs10000Per-request timeout (ms)
waittruefalse queues fire-and-forget; returns passthrough immediately
redactPiifalseOptional client-side scrub; server-side scrub is always on

Idempotency

The SDK auto-generates an Idempotency-Key per trace() call. Duplicate keys within the 24-hour window return the cached response. To control retries explicitly, pass metadata: { idempotencyKey } and use a stable upstream identifier.

Errors

ErrorCause
AdjudonBlockedErrorPolicy returned block; thrown when failMode: "closed"
AdjudonAuthErrorInvalid API key; never retried; always thrown
AdjudonRateLimitErrorRetries exhausted on 429; thrown when failMode: "closed"
AdjudonConfigErrorConstructor argument invalid

failMode: "open" returns { status: "passthrough" } for every network or rate-limit failure except AdjudonAuthError and AdjudonBlockedError — the first is a configuration bug, the second is a compliance signal you must not swallow.

Framework adapters

The core package is what most teams need. Per-provider adapters auto-instrument the popular Node-side AI SDKs so a single import records every model call:

PackageWraps
@adjudon/openaiOpenAI Node SDK
@adjudon/anthropicAnthropic SDK
@adjudon/azure-openaiAzure OpenAI
@adjudon/bedrockAWS Bedrock
@adjudon/cohereCohere
@adjudon/mistralMistral AI
@adjudon/vertexGoogle Vertex AI
@adjudon/vercel-aiVercel AI SDK
@adjudon/langchainLangChain.js
@adjudon/llamaindexLlamaIndex.TS

The OpenTelemetry exporter is documented at OpenTelemetry.

Resources

  • Quickstart — first trace in 60 seconds
  • Authentication — API key formats
  • Traces API — the underlying HTTP surface this SDK calls
  • Error Codes — HTTP-level errors this SDK raises
  • GitHub: github.com/adjudon/adjudon-node
  • npm: npmjs.com/package/@adjudon/node
  • Changelog: ships with each release on GitHub