Skip to content

Get started

pistra is the AI enforcement layer. Every model, tool and agent call is checked against your policy in line. Every decision leaves a signed record you can prove to anyone.

One provider, no config file, no migration:

Terminal window
$ pistra -listen :8484 -upstream https://api.openai.com
Two tutorials, each building a working configuration from nothing. The first puts pistra in front of a provider as the listener. The second runs it as an inspector behind a gateway you already have.

Read Silent degradation first if you are deciding whether this belongs in front of your traffic. It covers the failure mode worth checking any gateway for, quietly doing less than it claims, the seven places pistra is built against it, and the metric that verifies each one. The threat model says what is not claimed.

One binary, three shapes. Which one you are building decides which of the pages below apply to you. Architecture draws all three if none of them is obviously you.

The second fork. Each rung adds something and costs something to operate, and a deployment takes them on in about this order. Nothing on a higher rung is required by a lower one. Deployment requirements is the argument behind the order, and pistra check says which rungs a given file is on.

Govern

virtual keys, team profiles, budgets, CEL access rules, a signed audit trail, and a configuration you write through an API.

Requires: nothing more than the node already runs, plus an admin door on it, either the local socket or a loopback listener.

Mint, rotate and revoke a virtual key · Give a team its own policy · Cap what a team spends · Test your rules before they ship · Audit your metering against the provider · Query the gateway's state · Suspend a key, provider or rule · Verify the audit trail · Ship the audit trail to your SIEM · Manage the configuration through the API · Manage the deployment with Terraform · Store a secret through the API

Inspect

PII, secret and identifier detection on the pattern tier, redaction and restore, guardrail rules over what was found.

Requires: nothing more. and beside a gateway it needs that gateway's ext_proc.

Guard traffic you don't route · Deploy guardrails beside your gateway · Redact PII from model output · Run a slow detector off the request path · Run a detector in shadow mode · Exempt placeholders from a credential rule · Add your own recognizer · Find Gulf identifiers · Start from a control pack · Write a control pack · Measure a detector

Identify

tokens from your identity provider on both planes, the agent and the user in every rule, admin roles from claims, sign-in from the command line, and a credential exchanged per caller at an MCP server or agent.

Requires: an identity provider you administer, and a Cedar policy file for the admin plane.

Connect your identity provider · Sign in from the command line · Restrict what an admin caller can do · Authenticate agents with your identity provider · Reach the admin API without your identity provider · Connect your AI governance platform

Front peers

MCP servers and A2A agents behind the same keys, rules, budgets and guardrails, each agent's card projected at the gateway's address, and a private MCP registry.

Requires: a public_url, for the cards and the resource metadata a client asks for.

Front a peer agent · Serve a private MCP registry

Detectors

What finds something in the content. Six types, cheapest first: patterns and checksums, a token classifier, a sequence classifier, an embedding model, an LLM judge, or a Presidio you already run. All of them only annotate, so choose on cost and evidence.

Overview · Stop prompt injection with a classifier · Keep the assistant on topic with examples · Judge with a model · Detect names with a model from the HuggingFace Hub · Add your own recognizer · Find Gulf identifiers · Measure a detector

Control packs

One reading of a regulatory regime, published as data: rules that cite the regime's controls, a suite that proves what they decide, and a page naming what each pack leaves to you. A pack certifies nothing, and after `pack add` copies it in, the document is yours.

Overview · Control packs · The control pack format · Write a control pack · Start from a control pack · Saudi Personal Data Protection Law · NDMO data classification · SAMA Cyber Security Framework · SDAIA AI ethics and generative AI guidelines

MCP and peer agents

Tool calls and agent-to-agent calls governed the same way model calls are. An MCP server is a provider whose arguments and results are segments. A peer agent is one whose message parts are. The same detectors and rules apply to both.

Front a peer agent · Serve a private MCP registry

Operate the cluster

Day-two operation: what to scrape, what to alert on, how to verify the audit trail, how to restore state, and the two break-glass doors. Each recovery step is a command rather than a configuration edit.

Overview · Watch the gateway · Query the gateway's state · Verify the audit trail · Ship the audit trail to your SIEM · Back up and restore the cluster · Recover a cluster that has lost quorum · Suspend a key, provider or rule · Reach the admin API without your identity provider

How pistra is built, and what it does not claim. Start with the architecture page for the overall shape, then read the page covering whichever design decision you need to understand.
Generated from the code and tested against it. No page here is written by hand, so an error on one of these pages points at the code it reads.

These are filed under four kinds of document: tutorial, how-to, reference and explanation. The overview says what each kind is for and why they are kept apart.