open-guardrail
v2.5.0
Published
Open-source guardrail engine for LLM apps — 350 guards, 26 PII regions, 8 SDK adapters, zero API calls, <0.1ms latency, agent safety, GDPR/ISMS-P/PIPA compliance
Maintainers
Readme
open-guardrail
Open-source guardrail engine for LLM applications.
Provider-agnostic text input/output middleware. Works in Node.js, browsers, and edge runtimes.
Install
npm install open-guardrailQuick Start
import { pipe, promptInjection, pii, keyword } from 'open-guardrail';
const result = await pipe(
promptInjection({ action: 'block' }),
pii({ entities: ['email', 'phone'], action: 'mask' }),
keyword({ denied: ['hack', 'exploit'], action: 'block' }),
).run('user input text here');
if (!result.passed) {
console.log('Blocked:', result.action);
}YAML Config
version: "1"
pipelines:
input:
mode: fail-fast
guards:
- type: prompt-injection
action: block
- type: pii
action: mask
config:
entities: [email, phone]import { OpenGuardrail } from 'open-guardrail';
const engine = await OpenGuardrail.fromConfig('./guardrail.yaml');
const result = await engine.run(text);30 Built-in Guards
| Category | Guards | |----------|--------| | Security | promptInjection, regex, keyword | | Privacy | pii | | Content | toxicity, topicDeny, topicAllow, bias, language | | Format | wordCount, schemaGuard | | AI Delegation | llmJudge, hallucination, relevance, groundedness | | Operational | costGuard, rateLimit, dataLeakage, sentiment | | Agent Safety | toolCallValidator, codeSafety | | Advanced | copyright, watermarkDetect, multiTurnContext | | Korea/ISMS | piiKr, profanityKr, residentId, creditInfo, ismsP, pipa |
Key Features
- StreamingPipeline — chunk-level real-time guard validation
- GuardRouter — risk-based pipeline routing (low/medium/high)
- AuditLogger — EU AI Act / Korean AI Basic Act compliance logging
- Vercel AI SDK — middleware adapter (
open-guardrail-vercel-ai) - 8 Presets — default, strict, korean, security, content, ai-basic-act-kr, eu-ai-act
- Event hooks — guard:before, guard:after, guard:blocked, guard:error
- Dry run mode — test guards without blocking
- Provider agnostic — works with any LLM, any framework
Packages
| Package | Description |
|---------|-------------|
| open-guardrail | All-in-one (core + 30 guards) |
| open-guardrail-core | Core engine only |
| open-guardrail-guards | Guards only |
| open-guardrail-cli | CLI tools |
| open-guardrail-vercel-ai | Vercel AI SDK adapter |
License
MIT
