Interface for executing multiple guardrails in sequence or parallel.
const chain = new GuardrailChain({ guardrails: [piiGuardrail, injectionGuardrail, topicGuardrail], stopOnFirstFailure: true, parallel: false,});const result = await chain.execute({ content: userInput, contentType: 'input', userId: '123',});if (!result.passed) { throw new Error(`Guardrail violations: ${result.totalViolations}`);} Copy
const chain = new GuardrailChain({ guardrails: [piiGuardrail, injectionGuardrail, topicGuardrail], stopOnFirstFailure: true, parallel: false,});const result = await chain.execute({ content: userInput, contentType: 'input', userId: '123',});if (!result.passed) { throw new Error(`Guardrail violations: ${result.totalViolations}`);}
Execute all guardrails against content
Evaluation context
Aggregated result
Add a guardrail to the chain
Guardrail to add
Remove a guardrail from the chain
Name of guardrail to remove
true if removed
Get all guardrails in the chain
Array of guardrails
Readonly
Configuration for this chain
Interface for executing multiple guardrails in sequence or parallel.
Example