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.
Metadata
Release files for openguardrails 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| openguardrails-0.2.0.tar.gz | 23.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openguardrails-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.5 kB
Release files / openguardrails-0.2.0.tar.gz
| Download URL | openguardrails-0.2.0.tar.gz |
|---|---|
| Size | 23.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08039eef3eb41b07e27fba0d9b59e372a3049bb72287a62b7fccf57fbf6e01a7
|
|
BLAKE2b-256 checksum How to use checksums |
53694748f7b4ea1f9ddf2db4047e583267fd545d1c42d39cceae7d8936c064ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.
Transparency logRelease files / openguardrails-0.2.0-py3-none-any.whl
| Download URL | openguardrails-0.2.0-py3-none-any.whl |
|---|---|
| Size | 21.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7517925a378a83dce90210f3db465b3ca107e3403927015a30067ce9adb58919
|
|
BLAKE2b-256 checksum How to use checksums |
2471a329a0a5dcb041708307ac424a4cfcfd863523af6365dc2751cdb6217dbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.
Transparency logSecurity for openguardrails 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for openguardrails-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.