Skip to main content

Overrule SDK

Overrule

Don't ship AI you can't govern.

Runtime policy enforcement for LLM applications — intercept every call, enforce policies, block violations, and ship structured audit events to your cloud dashboard. One SDK. Sub-millisecond. EU AI Act ready.

QuickstartFeaturesArchitectureAPIPerformanceDevelopment


The Problem

Teams shipping AI to production face:

  • No runtime guardrails — LLM calls go live unchecked, PII leaks to model providers
  • Invisible AI decisions — no audit trail of what the model said, what policies applied, or what was blocked
  • Injection vulnerabilities — prompt injection and SQL injection attacks reach production without detection
  • Compliance theater — PDF policies and Notion docs that don't actually enforce anything at runtime
  • EU AI Act enforcement — Articles 13/14/15 require runtime logging, human oversight, and accuracy monitoring starting August 2026. Fines up to €35M / 7% revenue.

Existing solutions are either enterprise GRC platforms ($50k+/yr), manual review processes, or non-existent for actual runtime enforcement.

The Solution

Overrule is a Python SDK that wraps any LLM call with policy enforcement, violation detection, and structured audit events — all in under 1 millisecond.

from overrule import Guard

async with Guard() as guard:
    response = await guard.chat(
        model="gpt-4o",
        messages=[{"role": "user", "content": user_input}],
        policies=["pii-detection", "injection-detection"],
    )

That's it. Every call is now scanned for PII and injection attacks, violations are blocked before reaching users, and a structured event is shipped to your cloud dashboard.


Features

For AI Engineers

Feature Description
1-Line Integration Wrap any LLM call with guard.chat(). Works with OpenAI, Anthropic, any provider.
PII Detection Credit cards, SSN, email, phone, IBAN, passport, IPv4 — intercepted at runtime
Injection Detection 8 prompt injection + 5 SQL injection patterns blocked before they reach the model
Custom Policies Extend BasePolicy for domain-specific rules (toxicity, bias, topic restriction)
Multi-Provider Same governance across OpenAI, Anthropic — swap providers without touching policy logic
Async + Sync Guard for async, SyncGuard for synchronous — same API surface
Decorator API @guard.protect() for function-level enforcement
Standalone Evaluation guard.evaluate(text) to scan content without making an LLM call

For Platform Teams

Feature Description
Fail-Open Architecture SDK errors never crash your application. Governance degrades gracefully.
Circuit Breaker Opens after 5 consecutive failures, 30s cooldown, automatic recovery
Bounded Buffer 10K event max buffer with graceful shutdown flush
Exponential Backoff Jittered retry on transport failures — no thundering herd
Zero Hot-Path Latency Policies evaluate locally (<1ms). Telemetry ships async in background.
Cloud Event Streaming Every governance decision streamed to Overrule dashboard in real-time
Structured Violations Severity-tagged (low/medium/high/critical) with full context and direction
Environment Config OVERRULE_API_KEY, OVERRULE_ENDPOINT, OVERRULE_FAIL_OPEN — all env-configurable

For Compliance

Feature Description
EU AI Act Articles 13/14/15 Maps directly to logging, oversight, and accuracy requirements
Structured Audit Trail Every LLM interaction logged with model, provider, tokens, latency, policies, violations
Exportable Telemetry Events in structured format for auditors and regulators
Runtime Enforcement Governance is code, not a document. Prove to regulators what's actually enforced.
Cloud Dashboard Visual overview at overrule.dev — posture score, events, policies, billing

Quickstart

Installation

pip install overrule               # Core SDK
pip install overrule[openai]       # + OpenAI provider
pip install overrule[anthropic]    # + Anthropic provider
pip install overrule[all]          # All providers

Configuration

export OVERRULE_API_KEY=sk_ovr_your_key_here   # from https://overrule.dev/dashboard
export OPENAI_API_KEY=sk-...                    # your LLM provider key

That's all you need. The SDK auto-connects to https://overrule.dev/api and streams events to your dashboard.

Or configure programmatically:

from overrule import Guard, GuardConfig

guard = Guard(config=GuardConfig.from_env(api_key="sk_ovr_xxxxx", fail_open=True))

Basic Usage

from overrule import Guard

async with Guard() as guard:
    response = await guard.chat(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Hello, what's the weather?"}],
        policies=["pii-detection", "injection-detection"],
    )
    # ✓ Policies evaluated (<1ms)
    # ✓ Violations blocked (if any)
    # ✓ Event streamed to dashboard

Verify Your Integration

Run this after installing to confirm events reach your dashboard:

python -c "
import asyncio
from overrule import Guard

async def verify():
    async with Guard() as guard:
        result = await guard.evaluate('test@email.com SSN 123-45-6789', policies=['pii-detection'])
        print(f'PII detected: {len(result.violations)} violations')
        await guard._reporter._flush()
        print('✓ Events sent — check https://overrule.dev/dashboard')

asyncio.run(verify())
"

Environment Variables

Variable Default Description
OVERRULE_API_KEY Your API key from overrule.dev dashboard
OVERRULE_ENDPOINT https://overrule.dev/api Cloud endpoint for event ingestion
OVERRULE_ENVIRONMENT production Environment tag on events
OVERRULE_FAIL_OPEN true If true, SDK errors don't crash your app
OVERRULE_BATCH_SIZE 50 Events batched before flush
OVERRULE_FLUSH_INTERVAL 5.0 Seconds between background flushes

How It Works

┌─────────────────────────────────────────────────────────────┐
│                      Your Application                        │
│                                                              │
│  response = await guard.chat(model=..., policies=[...])     │
└──────────────────────────────┬──────────────────────────────┘
                               │
                    ┌──────────▼──────────┐
                    │    Overrule Guard    │
                    │                     │
                    │  1. Input policies  │
                    │  2. LLM call        │
                    │  3. Output policies │
                    │  4. Event ship      │
                    └──────────┬──────────┘
                               │
          ┌────────────────────┼────────────────────┐
          │                    │                    │
┌─────────▼──────┐  ┌─────────▼──────┐  ┌─────────▼──────┐
│  Policy Engine │  │   LLM Provider │  │  Event Buffer  │
│  (local, <1ms) │  │   (OpenAI /    │  │  (async ship   │
│                │  │    Anthropic)  │  │   to cloud)    │
│  PII Detection │  │                │  │                │
│  Injection Det │  │                │  │  10K bounded   │
│  Custom Rules  │  │                │  │  Backoff retry │
└────────────────┘  └────────────────┘  └───────┬────────┘
                                                │
                                     ┌──────────▼──────────┐
                                     │  Overrule Cloud     │
                                     │  POST /api/v1/events│
                                     │                     │
                                     │  Dashboard, Alerts, │
                                     │  Compliance Reports │
                                     └─────────────────────┘

Key design decisions:

Decision Rationale
Policies evaluate locally Zero network latency on the hot path
Telemetry ships async Your app never waits on governance infrastructure
Fail-open by default A governance SDK that crashes your app is worse than no governance
Circuit breaker 5 failures → open → 30s cooldown → half-open → recover
Bounded buffer Memory-safe: drops oldest events at 10K rather than OOM

API Reference

Guard

from overrule import Guard, SyncGuard

# Async (recommended)
async with Guard() as guard:
    response = await guard.chat(model, messages, policies)

# Sync
with SyncGuard() as guard:
    response = guard.chat(model, messages, policies)

guard.chat()

Intercept an LLM call with policy enforcement.

response = await guard.chat(
    model="gpt-4o",
    messages=[{"role": "user", "content": "..."}],
    policies=["pii-detection", "injection-detection"],
    provider="openai",  # or "anthropic"
)

guard.evaluate()

Standalone content evaluation without making an LLM call.

result = await guard.evaluate(
    "My SSN is 123-45-6789",
    policies=["pii-detection"]
)

result.passed       # False
result.violations   # [Violation(policy_id="pii-detection", pattern="ssn", ...)]

@guard.protect()

Decorator for function-level enforcement.

from overrule import Guard, PolicyAction

guard = Guard()

@guard.protect(policies=["injection-detection"], action=PolicyAction.BLOCK)
async def query_database(sql: str) -> str:
    return await db.execute(sql)

guard.register_policy()

Register custom policies.

from overrule.policies.base import BasePolicy, PolicyResult
from overrule.models.violation import Violation

class TopicRestriction(BasePolicy):
    policy_id = "topic-restriction"

    def evaluate(self, content: str, *, direction: str = "input") -> PolicyResult:
        if "medical advice" in content.lower():
            return PolicyResult(
                passed=False,
                violations=[Violation(
                    policy_id=self.policy_id,
                    severity="high",
                    description="Medical advice is restricted",
                )],
            )
        return PolicyResult(passed=True, violations=[])

guard.register_policy(TopicRestriction)

Built-in Policies

Policy ID What It Detects
pii-detection Credit cards, SSN, email, phone, IBAN, passport numbers, IPv4 addresses
injection-detection 8 prompt injection patterns + 5 SQL injection patterns

Policy Actions

Action Behavior
PolicyAction.BLOCK Raise exception, do not execute LLM call
PolicyAction.LOG Log violation, continue execution
PolicyAction.PASS Record event, no enforcement

Performance

Metric Value
Policy evaluation <1ms
Network calls on hot path 0
Buffer capacity 10,000 events
Flush interval 5s (configurable)
Test suite 78 tests passing
Python versions 3.10 · 3.11 · 3.12 · 3.13 · 3.14

Security

  • API keys never exposed in repr(), str(), or serialized output
  • PII redaction shows only last 4 characters (no BIN/prefix leakage)
  • Content truncation emits a warning when policy evaluation is partial
  • Config values are bounds-validated (batch_size, flush_interval, etc.)
  • PEP 561 compliant (py.typed marker for downstream type checking)
  • Fail-open design ensures SDK errors never crash your application
  • No secrets in logs — all sensitive values masked in debug output

Cloud Dashboard

The Overrule cloud dashboard at overrule.dev provides:

Feature Description
Posture Score At-a-glance governance health metric
Event Stream Filterable, paginated log of every governed LLM call
Policy Metrics Effectiveness rates, violation counts, status per policy
API Key Management Create, revoke, usage tracking — plan-gated limits
Billing Stripe-powered subscription management with usage metering
Settings Webhook configuration, profile, account management

Plans

Free Starter Team Enterprise
Events/month 1,000 25,000 200,000 Unlimited
API keys 10 25 100 Unlimited
Rate limit 120/min 500/min 2,000/min 10,000/min
Retention 7 days 30 days 90 days 365 days
Price Free $39/mo $149/mo Custom

Project Structure

overrule-sdk/
├── overrule/
│   ├── __init__.py              # Public API (Guard, SyncGuard, PolicyAction)
│   ├── guard.py                 # Core Guard class (async context manager)
│   ├── sync_guard.py            # Synchronous Guard wrapper
│   ├── config.py                # GuardConfig (env + programmatic)
│   ├── circuit_breaker.py       # Circuit breaker (closed/open/half-open)
│   ├── buffer.py                # Bounded event buffer (10K max)
│   ├── transport.py             # HTTP transport (backoff, jitter, retry)
│   ├── models/
│   │   ├── event.py             # Structured governance event
│   │   └── violation.py         # Violation model (policy_id, severity, direction)
│   ├── policies/
│   │   ├── base.py              # BasePolicy abstract class
│   │   ├── pii.py               # PII detection (regex-based)
│   │   └── injection.py         # Prompt + SQL injection detection
│   └── providers/
│       ├── openai.py            # OpenAI provider adapter
│       └── anthropic.py         # Anthropic provider adapter
├── tests/                       # 78 tests (pytest)
├── pyproject.toml               # Build config + dependencies
└── LICENSE                      # MIT

Compliance Mapping

EU AI Act Requirement Overrule Implementation
Art. 13 — Transparency & logging Every LLM call logged with model, tokens, latency, policies, violations
Art. 14 — Human oversight Dashboard shows real-time enforcement stream, violation alerts
Art. 15 — Accuracy & robustness Policy enforcement prevents degraded/adversarial outputs
Audit evidence Structured event export for regulators
Enforcement date August 2, 2026 — fines up to €35M / 7% global revenue

Roadmap

  • Core Guard with fail-open architecture
  • PII detection policy (credit cards, SSN, email, phone, IBAN, passport, IPv4)
  • Injection detection policy (8 prompt injection + 5 SQL injection patterns)
  • Async + Sync APIs (Guard + SyncGuard)
  • Multi-provider support (OpenAI + Anthropic)
  • Custom policy engine (BasePolicy interface)
  • Decorator API (@guard.protect())
  • Standalone evaluation (guard.evaluate())
  • Circuit breaker (5 failures → open → 30s cooldown → recovery)
  • Bounded event buffer (10K max, graceful shutdown flush)
  • Exponential backoff with jitter on transport failures
  • Cloud event streaming (POST /api/v1/events)
  • Environment-based configuration
  • Published on PyPI (pip install overrule)
  • 78-test suite (pytest)
  • PEP 561 compliant (py.typed)
  • Streaming interception (token-by-token policy evaluation)
  • LangChain integration (OverruleCallback)
  • CrewAI integration (agent-level governance)
  • OpenAI Agents SDK wrapper
  • Rust core for <100μs evaluation
  • Output policy enforcement (response scanning)
  • Policy marketplace (community-contributed policies)

Examples

The examples/ directory contains runnable scripts for common use cases:

Example Description Requires LLM Key
quickstart.py Full integration test — LLM call + PII + injection Yes
evaluate_only.py Policy evaluation without LLM calls No
custom_policy.py Build your own policy (topic restriction, length limits) No
sync_usage.py Synchronous API for scripts and notebooks No
# Run any example
cd overrule-sdk
export OVERRULE_API_KEY=sk_ovr_...
python examples/evaluate_only.py

Development

# Clone
git clone https://github.com/overruledev/overrule-sdk.git
cd overrule-sdk

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint + type check
ruff check .
mypy overrule/

Contributing

We're building in public. Contributions welcome.

# Fork + clone
git clone https://github.com/yourusername/overrule-sdk.git

# Create feature branch
git checkout -b feature/your-feature

# Make changes, then
pytest                          # Ensure tests pass
ruff check .                    # Lint
mypy overrule/                  # Type check
git commit -m "feat: your feature description"
git push origin feature/your-feature

Contact

Purpose Email
General inquiries hello@overrule.dev
Customer support support@overrule.dev
Enterprise sales sales@overrule.dev
Founder founders@overrule.dev

License

MIT License. See LICENSE for details.


Built for teams shipping AI to production.
Overrule — because governance shouldn't slow you down.

Download files

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

Source Distribution

overrule-0.1.1.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

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

overrule-0.1.1-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file overrule-0.1.1.tar.gz.

File metadata

  • Download URL: overrule-0.1.1.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for overrule-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3539ce8dff380a3cd61591beb5bdbd9f3706c8ac2bad5579d441d30a9037317a
MD5 526a049dcd606beb4c9799f0d48bbb73
BLAKE2b-256 3dfce94e68ea63a1a86242595c354331ac7f48c20945a9be37112fef05012237

See more details on using hashes here.

File details

Details for the file overrule-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: overrule-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for overrule-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77011831cd0c9866813c9c6222c7033fe4266322b12a18678fcd60905bcde9f6
MD5 9432ebefdcf0bad4ec9789e6e0f9686a
BLAKE2b-256 f2eac04b4c63a68419c93b159805773f6060f49df4ef4455fd6adf6dca12b125

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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