AI Guardrails.
Ship safer AI — before it reaches your users.
Langtrain Guardrails is a configurable content safety layer for LLM inputs and outputs. Block PII leakage, profanity, prompt injections, and custom policy violations.
What you get
Everything you need — nothing you don't.
PII Detection
Automatically detect and mask phone numbers, emails, SSNs, Aadhaar, passports, and custom PII patterns before data hits the LLM.
Profanity & Toxicity
Multi-lingual toxicity detection powered by fine-tuned classifiers. Configure sensitivity levels per language.
Custom Regex Rules
Write your own regex-based rules for domain-specific content (e.g., internal product codes, confidential project names).
Prompt Injection Shield
Detect and block adversarial jailbreak attempts and system prompt extraction attacks in real time.
Output Validation
Validate model outputs against your schema. Ensure JSON structure, length limits, and domain compliance before returning to users.
Inline or Sidecar
Deploy as middleware in your API gateway, or use our SDK to wrap any model call. Works with OpenAI, Anthropic, and fine-tuned models.
How it works
From zero to production in 5 steps.
Define your policy
Choose from built-in guardrails (PII, profanity, toxicity) and add custom regex or classifier rules.
Attach to your pipeline
Wrap your model endpoint with the Langtrain guardrail middleware. One import, zero latency overhead on most rules.
Set actions
For each rule, define: block, redact, replace, or flag. Blocked requests return a configurable fallback message.
Monitor violations
Every guardrail hit is logged in LangVision with the offending content, rule triggered, and user context.
Tune & iterate
Adjust sensitivity thresholds based on false positive rates. Promote rules to production with one click.
SDK snippet
Integrate in minutes.
from langtrain.guardrails import GuardrailsClient
guard = GuardrailsClient(api_key="lt_...")
result = guard.check(
text="My SSN is 123-45-6789, email me at john@acme.com",
rules=["pii", "profanity"],
action="redact" # or "block" / "flag"
)
print(result.output)
# → "My SSN is [REDACTED], email me at [REDACTED]"
print(result.violations)
# → [{"rule": "pii", "type": "SSN"}, {"rule": "pii", "type": "email"}]