> ## 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.

## Coverage

| Surface    | Monitor | Block | Redact |
| ---------- | :-----: | :---: | :----: |
| LLM input  |    ✅    |   ⚠️  |   ⚠️   |
| LLM output |    ✅    |   ⚠️  |   ⚠️   |
| Tool-level |    ⚠️   |   ⚠️  |   ⚠️   |

**Ask** — `status` is advisory: nothing prompts anyone unless your code does.

**Use it when** the model call lives in your JavaScript or TypeScript code and
the policy decision needs application context. **Not as your only defence when**
you need a guarantee that does not depend on every developer remembering the
check.

⚠️ TrustGuard returns the verdict, your code enforces it. Ignoring
`transformedPayload` silently disables redaction: the call succeeds, the finding
is recorded, and the unmasked prompt reaches the model.

**Limits.** Coverage is per call site — see
[Node middleware](/trustguard/integrations/node-middleware) to cover
by configuration instead.

Full comparison: [Coverage](/trustguard/integrations/coverage).

```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)");
```
