--- id: openai-guardrails version: "0.3.0" license: MIT license_treatment: permissive maintenance: active --- # openai-guardrails — OpenAI Guardrails: A framework for building safe and reliable AI systems. License: permissive · Maintenance: active · Downloads: 315.2K/mo ## What it is and what it does OpenAI Guardrails is a Python wrapper around OpenAI's client that intercepts and validates LLM requests and responses against configurable safety rules. It provides a drop-in replacement for the standard OpenAI client, letting you add guardrails without rewriting your application code. The package includes built-in checks for content moderation, PII detection, jailbreak attempts, hallucination detection, NSFW content, off-topic prompts, and URL filtering, all configured via JSON. The package depends on openai, openai-agents, presidio-analyzer, pydantic, and thinc. It integrates with OpenAI's Agents SDK via GuardrailAgent for agent-based workflows and includes an evaluation framework to benchmark guardrail performance on labeled datasets. When a guardrail is triggered, it raises GuardrailTripwireTriggered, allowing you to handle violations gracefully. The spaCy model for PII detection is an optional but documented prerequisite if that guardrail is enabled. Use it for: - Protect customer-facing chatbots from jailbreak attempts and inappropriate content without modifying core chat logic. - Detect and mask personally identifiable information in LLM inputs and outputs to meet data privacy compliance. - Evaluate guardrail effectiveness on labeled datasets and benchmark different model configurations for safety performance. - Integrate safety checks into OpenAI Agents SDK workflows to ensure agent outputs meet compliance requirements. - Filter hallucinated or off-topic responses to keep LLM outputs within business scope and factual accuracy. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Adds configurable safety and compliance guardrails to LLM applications by wrapping OpenAI's Python client to automatically validate and moderate inputs and outputs against a wide range of built-in checks. Yes, if you need to add safety and compliance checks to an OpenAI-based LLM application. The package is actively maintained, has low install friction, uses a permissive MIT license, and offers a drop-in integration pattern that minimizes code changes. It is still in preview (version 0.3.0), so expect potential API changes; verify stability for production use cases before committing to it. ## Install pip install openai-guardrails uv add openai-guardrails poetry add openai-guardrails ## Installing openai-guardrails Before you install: Low install friction with a pure-Python wheel. Active maintenance (last commit 2026-07-21, 24 days old). Requires Python 3.11 or later. The spaCy model for PII detection must be downloaded separately if that guardrail is enabled, which is documented as a prerequisite during client initialization. License in practice: MIT license (permissive) means you can use, modify, and distribute this package freely in commercial and open-source projects. No copyleft obligations. Quickstart: pip install openai-guardrails from pathlib import Path from guardrails import GuardrailsOpenAI client = GuardrailsOpenAI(config=Path("guardrail_config.json")) chat = client.chat.completions.create( model="gpt-5", messages=[{"role": "user", "content": "Hello world"}], ) print(chat.choices[0].message.content) Requires Python 3.11+. If using the Contains PII guardrail, the spaCy model en_core_web_sm must be downloaded separately before client initialization. Verify before relying: - Whether the package's evaluation framework (guardrail_evals) is production-ready or still in preview like the main package. - Performance overhead of guardrail checks on typical LLM request latency. - Whether custom guardrails beyond the built-in set can be easily defined by users. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 315.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags llm safety guardrails, openai content moderation, pii detection python, jailbreak detection, llm input output validation, ai compliance framework, hallucination detection, llm-safety, content-moderation, compliance [View on SkillFed](https://skillfed.io/packages/openai-guardrails) · [View on PyPI](https://pypi.org/project/openai-guardrails/)