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
| Name | Type | Required | Description |
|---|---|---|---|
guardrail_id | string | Required | Guardrail identifier. |
input | string | Required | Input text to evaluate. |
mode | string | enforce or monitor mode. |
SDK parity
Method signatures are aligned across SDKs so migration between TypeScript and Python stays predictable.