openguardrails
The OpenGuardrails (OGR) SDK: the in-process reference runtime plus a
client for the Runtime API — a vendor-neutral enforcement protocol for AI
agent safety & security. Each agent action becomes a GuardEvent, runs past
whatever detectors you choose, and gets back a Verdict that can allow, block,
or require approval before the action runs. Security/safety vendors plug in
behind a single Detector interface, and deployers compose them with one policy.
The layering is API → SDK → Plugin: a runtime serves the HTTP API, this package
wraps it, and integrations build on the wrapper.
pip install openguardrails
Zero dependencies (stdlib only).
The contract in 30 seconds
from openguardrails import Runtime, GuardEvent
from openguardrails.detectors.config_rules import ConfigRulesDetector
from openguardrails.detectors.llm_judge import LLMJudgeDetector
rt = Runtime(
detectors=[ConfigRulesDetector(policy["config_rules"]), LLMJudgeDetector()],
policy=policy, # composition + rules, deployer-owned
)
verdict = rt.evaluate(GuardEvent(...)) # -> allow | block | require_approval | redact | modify
GuardEvent— a normalized observation of an agent action (a tool call, an exec, model I/O) plus its provenance (trust labels on the inputs that produced it). The same wire type at every altitude.Detector— the competitive surface. A detector is OGR-conformant if it maps aGuardEventto aVerdict. Rules, a classifier, or a hosted model — your choice.provideris its stable identity for attribution and benchmarking.Runtime— the PDP: fans out to detectors, composes their verdicts (deny-wins / quorum / first-available), propagates provenance, and correlates altitudes byguard_idso a later observation point can only tighten an earlier decision.
Talk to a runtime (RuntimeClient)
When the PDP is a deployed OGR runtime rather than the in-process one, the same
GuardEvent/Verdict types go over HTTP. base_url is the API root — the
client appends the canonical /v1/* paths, so a runtime mounted behind a
prefix takes the full prefix (e.g. https://host/api/public/ogr). A bare
deployment base URL also works against older runtimes that mount the API only
at /api/public/ogr: a route-level 404 on a canonical path is retried once on
the legacy mount and the discovered mount is cached per client. Both
arguments default to OGR_RUNTIME_URL / OGR_API_KEY.
from openguardrails import RuntimeClient, RateLimitedError
client = RuntimeClient("https://host/api/public/ogr", "ogr_...")
verdict = client.evaluate(event) # POST /v1/evaluate -> Verdict
results = client.ingest([event1, event2]) # POST /v1/ingest (batched, 207)
client.get_approval(event.guard_id) # {"status": "pending" | ...}
Ed25519 detached-JWS request signing (Ed25519Signer, header
ogr-batch-signature) is optional and needs the cryptography package;
BatchingIngestor gives fire-and-forget background ingest with an atexit
drain. Everything else stays stdlib-only.
Write a detector (the whole vendor surface)
from openguardrails.detectors import Detector
from openguardrails import Verdict, Category
class AcmeInjectionDetector(Detector):
provider = "acme.injection"
handles = ("tool_call", "exec", "model_output")
def evaluate(self, ev):
... # rules, classifier, or hosted model
return Verdict(ev.event_id, ev.guard_id, self.provider, "block",
categories=[Category("security.prompt_injection", "security", 0.97)])
Instrument an agent
To guard a real agent, install a per-target instrumentation package:
openguardrails-instrumentation-hermes— secures a Hermes agent across the gateway, tool-call hook, and sandbox exec.
Status
Implements protocol 0.4 — reference implementation validating the
specification. The wire
contract is the product; this runtime is the proof it runs.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openguardrails-0.2.0.tar.gz.
File metadata
- Download URL: openguardrails-0.2.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08039eef3eb41b07e27fba0d9b59e372a3049bb72287a62b7fccf57fbf6e01a7
|
|
| MD5 |
3717f31e0ee52f911b150c3064cff839
|
|
| BLAKE2b-256 |
53694748f7b4ea1f9ddf2db4047e583267fd545d1c42d39cceae7d8936c064ea
|
Provenance
The following attestation bundles were made for openguardrails-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on openguardrails/openguardrails
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openguardrails-0.2.0.tar.gz -
Subject digest:
08039eef3eb41b07e27fba0d9b59e372a3049bb72287a62b7fccf57fbf6e01a7 - Sigstore transparency entry: 2421408997
- Sigstore integration time:
-
Permalink:
openguardrails/openguardrails@fc68c93091b6a5cef705ff05b424de0b82675f9f -
Branch / Tag:
refs/tags/python-v0.2.0 - Owner: https://github.com/openguardrails
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@fc68c93091b6a5cef705ff05b424de0b82675f9f -
Trigger Event:
push
-
Statement type:
File details
Details for the file openguardrails-0.2.0-py3-none-any.whl.
File metadata
- Download URL: openguardrails-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7517925a378a83dce90210f3db465b3ca107e3403927015a30067ce9adb58919
|
|
| MD5 |
da420b8eb7e731b46977602bf09a0dbe
|
|
| BLAKE2b-256 |
2471a329a0a5dcb041708307ac424a4cfcfd863523af6365dc2751cdb6217dbd
|
Provenance
The following attestation bundles were made for openguardrails-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on openguardrails/openguardrails
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openguardrails-0.2.0-py3-none-any.whl -
Subject digest:
7517925a378a83dce90210f3db465b3ca107e3403927015a30067ce9adb58919 - Sigstore transparency entry: 2421409053
- Sigstore integration time:
-
Permalink:
openguardrails/openguardrails@fc68c93091b6a5cef705ff05b424de0b82675f9f -
Branch / Tag:
refs/tags/python-v0.2.0 - Owner: https://github.com/openguardrails
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@fc68c93091b6a5cef705ff05b424de0b82675f9f -
Trigger Event:
push
-
Statement type: