direction on every call (input before
the model, output after). Defaults to input if omitted.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
@neuraltrust/trustguard-sdk — guard() with direction input/output.
direction on every call (input before
the model, output after). Defaults to input if omitted.
npm install @neuraltrust/trustguard-sdk
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)");