Guardrails API (TypeScript)

Methods, examples, and parameters for client.guardrails.

Module Overview

Attach safety policies and moderation checks before and after model execution.

Available Methods

  • client.guardrails.list() - List available guardrails.
  • client.guardrails.apply() - Apply a guardrail set to a request.
  • client.guardrails.test() - Run dry-run policy evaluations.

Examples

TypeScript
import { TheRouter.ai } from "@therouter/sdk";

const client = new TheRouter.ai({ apiKey: process.env.THEROUTER_API_KEY! });

const result = await client.guardrails.test({
  guardrail_id: "gr_content_safety",
  input: "Classify this message for risk.",
});

console.log(result.verdict);
guardrails-response.json
{
  "id": "req_01HXYZ123",
  "module": "guardrails",
  "status": "ok"
}

Parameter Types

NameTypeRequiredDescription
guardrail_id
stringRequiredGuardrail identifier.
input
stringRequiredInput text to evaluate.
mode
stringenforce or monitor mode.
SDK parity
Method signatures are aligned across SDKs so migration between TypeScript and Python stays predictable.