Documentation / Node SDK
Node SDK
@guardonic/sdk is open source (MIT). It sends agent run payloads to the Guardonic API with POST /v1/ingest and the x-api-key header. Source: github.com/guardonic/guardonic-node.
Point baseUrl at the API your operator gives you (hosted Guardonic API or your own guardonic-engine deployment). The SDK defaults to http://localhost:4000 for local development.
Install
From npm (when published):
From a clone of the repo: build, then npm link, or add a file: / workspace dependency in a monorepo.
$ cd guardonic-node
$ npm install
$ npm run build
$ npm link
Usage
const client = new Guardonic({
apiKey: process.env.GUARDONIC_API_KEY!,
baseUrl: "https://your-api.example", // optional; default http://localhost:4000
});
const { runId } = await client.ingest({
agent: "support-bot",
status: "running",
events: [
{
type: "llm",
label: "Request",
detail: "gpt-4o · 1200 tok",
},
],
});
ingest()returns{ ok: true, runId, contractVersion }.- Omit
runIdin the body to let the API create one; send the samerunIdon later calls to append events to that run. - On non-OK responses or invalid JSON, the client throws an
Errorwith the server message when available.
Constructor
GuardonicOptions:
apiKey(required) — same value as the API / engineGUARDONIC_API_KEY.baseUrl(optional) — origin only, no trailing slash; defaulthttp://localhost:4000.fetch(optional) — injectfetchfor tests or custom runtimes.
Ingest payload
IngestInput (all fields optional except what your pipeline requires):
runId— stable id for the run; omit to assign a new id.agent,status— strings (e.g. agent name,running/completed).events— array ofGuardonicEventInput:type(required),label,detail, optionalat(ISO time).summary— arbitrary JSON object for extra metadata.
Exported types: GuardonicEventInput, IngestInput, IngestResult.
Local development
To exercise the SDK against a real API, run guardonic-engine (NestJS) and MongoDB, then use the default http://localhost:4000 or set baseUrl. The repo includes examples/demo.mjs after npm run build.
HTTP contract
The client calls POST {baseUrl}/v1/ingest with application/json and header x-api-key. Hosted Guardonic APIs that follow the same contract are compatible.
Realtime updates (e.g. for a dashboard) use Socket.IO on the /v1/realtime namespace on the engine; the SDK does not ship a WebSocket client yet — use socket.io-client or a small wrapper if you need browser or Node subscriptions.
Current stable contract version: 2026-04-15.v1.
Environment
Your app should provide the API key (and optionally base URL) via config or env — for example:
# GUARDONIC_BASE_URL=https://api.example.com