Metadata-Version: 2.4
Name: open-guardrail
Version: 0.11.0
Summary: 350 guards for LLM safety — prompt injection, PII (26 regions), GDPR, EU AI Act, agent safety, zero API calls, <0.1ms
Project-URL: Homepage, https://github.com/wonjangcloud9/open-guardrail
Project-URL: Documentation, https://wonjangcloud9.github.io/open-guardrail/
Project-URL: Repository, https://github.com/wonjangcloud9/open-guardrail
Author-email: Lucas <wonjangcloud9@gmail.com>
License-Expression: MIT
Keywords: agent-safety,ai,anthropic,bias,compliance,content-filter,edge,eu-ai-act,gdpr,guardrail,hallucination,isms-p,langchain,llm,moderation,openai,pii,pipa,prompt-injection,safety,toxicity,zero-api
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# open-guardrail (Python)

**309 guards. Zero dependencies. Pure Python. <0.1ms latency.**

[![PyPI](https://img.shields.io/pypi/v/open-guardrail)](https://pypi.org/project/open-guardrail/)
[![Python](https://img.shields.io/pypi/pyversions/open-guardrail)](https://pypi.org/project/open-guardrail/)
[![License](https://img.shields.io/github/license/wonjangcloud9/open-guardrail)](LICENSE)
[![Tests](https://img.shields.io/badge/tests-560_passing-green)](https://github.com/wonjangcloud9/open-guardrail)

## Install

```bash
pip install open-guardrail
```

## Quick Start

```python
from open_guardrail import pipe, prompt_injection, pii, keyword

pipeline = pipe(
    prompt_injection(action="block"),
    pii(entities=["email", "phone"], action="mask"),
    keyword(denied=["hack", "exploit"], action="block"),
)

result = pipeline.run("user input text here")
if not result.passed:
    print(f"Blocked: {result.action}")
# result.output contains masked text when PII is detected
```

## 309 Built-in Guards

### Security
`prompt_injection` `indirect_injection` `sql_injection` `xss_guard` `secret_pattern` `invisible_text` `canary_token` `encoding_attack` `data_leakage` `data_exfiltration` `path_traversal` `command_injection` `ssrf_detect` `jailbreak_pattern` `api_key_detect` `social_engineering` `unicode_confusable` `ascii_art` `data_poisoning` `prompt_leak` `semantic_firewall` `multimodal_safety` `rag_safety` `token_smuggling` `prompt_chaining` `output_filter_bypass` `model_denial` `agent_permission` `supply_chain_detect` `instruction_hierarchy` `context_window_abuse`

### Privacy — 26 PII Regions
`pii` `pii_kr` `pii_jp` `pii_cn` `pii_th` `pii_ar` `pii_in` `pii_eu` `pii_de` `pii_fr` `pii_br` `pii_au` `pii_ca` `pii_mx` `pii_sg` `pii_id` `pii_ru` `pii_pl` `pii_es` `pii_it` `pii_tr` `pii_vn` `pii_ng` `pii_za` `pii_ke` `pii_eg`

### Compliance
`gdpr_compliance` `eu_ai_act` `ai_basic_act_kr` `isms_p` `pipa` `appi` `pipl` `hipaa_detect` `pci_dss_detect` `sox_compliance` `ferpa_detect` `privacy_policy`

### AI / LLM Safety
`hallucination_url` `reasoning_trace_leak` `persona_consistency` `confidence_score` `content_watermark` `rate_limit_semantic`

### Content Safety
`toxicity` `bias` `hate_speech` `violence_detect` `sexual_content` `self_harm_detect` `profanity_en` `profanity_kr` `profanity_jp` `profanity_cn`

### Agent Safety
`agent_loop_detect` `tool_abuse` `escalation_detect` `rag_poisoning`

[Full guard list →](https://github.com/wonjangcloud9/open-guardrail#241-built-in-guards)

## Guard Composition

```python
from open_guardrail import compose, when, parallel

# Bundle guards
security = compose("security",
    prompt_injection(action="block"),
    sql_injection(action="block"),
)

# Conditional execution
long_text_check = when(lambda t: len(t) > 200, toxicity(action="block"))

# Parallel execution
fast = parallel(prompt_injection(action="block"), toxicity(action="block"))
```

## License

MIT
