> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js SDK

> @neuraltrust/trustguard-sdk — guard() with direction input/output.

Create an API key on the collector first. Set `direction` on every call (`input` before
the model, `output` after). Defaults to `input` if omitted.

```bash theme={null}
npm install @neuraltrust/trustguard-sdk
```

```ts theme={null}
import { TrustGuard } from "@neuraltrust/trustguard-sdk";

const client = new TrustGuard({
  baseUrl: "<your-trustguard-url>",
  apiKey: "<collector-api-key>",
});

const inbound = await client.guard({
  payload: { input: userInput },
  direction: "input",
  consumerId: user.id,
  sessionId: conversationId,
});
if (inbound.isBlocked) throw new Error("Blocked by TrustGuard (input)");
const prompt = inbound.transformedPayload ?? { input: userInput };

// … model call …

const outbound = await client.guard({
  payload: { input: modelCompletion },
  direction: "output",
  consumerId: user.id,
  sessionId: conversationId,
});
if (outbound.isBlocked) throw new Error("Blocked by TrustGuard (output)");
```
