Skip to main content

350 guards for LLM safety — prompt injection, PII (26 regions), GDPR, EU AI Act, agent safety, zero API calls, <0.1ms

Project description

open-guardrail (Python)

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

PyPI Python License Tests

Install

pip install open-guardrail

Quick Start

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 →

Guard Composition

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_guardrail-0.7.0.tar.gz (228.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_guardrail-0.7.0-py3-none-any.whl (488.8 kB view details)

Uploaded Python 3

File details

Details for the file open_guardrail-0.7.0.tar.gz.

File metadata

  • Download URL: open_guardrail-0.7.0.tar.gz
  • Upload date:
  • Size: 228.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for open_guardrail-0.7.0.tar.gz
Algorithm Hash digest
SHA256 6ca4e81d136d44db2d04abf5e575d5be49778fe9c3625c060e121ea5c89d45fb
MD5 9d434678d22eee14425c6fd18a1b7f1a
BLAKE2b-256 32ec41a14635192277502591eb010efa04bb6593787b0a9e7bbc8a1f2894a55c

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_guardrail-0.7.0.tar.gz:

Publisher: publish-python.yaml on wonjangcloud9/open-guardrail

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file open_guardrail-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: open_guardrail-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 488.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for open_guardrail-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8739e5da35689e8ffce18cff1a426e4a88ee75779ae60a8cc174b570898d9a6b
MD5 c81ca02ced0f9622c39fd05f983bc911
BLAKE2b-256 09a2b31e3a5d3d4754cb4d7e87beec2f5a878b5f48f715466d2a0e98c2ced1ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_guardrail-0.7.0-py3-none-any.whl:

Publisher: publish-python.yaml on wonjangcloud9/open-guardrail

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page