Skip to content

Step 7 of 7: Deploy as a service

For gateways, back-end services and pipelines, run the engine as an HTTP service on your own infrastructure. The content it checks is the data itself, so never run it as a third-party cloud service.

A rule can depend on how a destination processes content. List the services you actually use in a destination registry, written by hand because only you know your contracts and approvals:

opp: "0.2.0.dev0"
name: acme-destinations
destinations:
  - id: hosted-llm
    category: external_ai
    endpoints: ["api.llm.example"]
    modes:
      - {id: api, mechanism: plaintext, plaintext_access: provider, key_custody: provider,
         retention: transient, assurance: asserted}
      - id: confidential
        mechanism: tee
        plaintext_access: enclave
        key_custody: provider
        retention: none
        region: eu
        assurance: verified
        evidence:
          - {kind: attestation, ref: "attestation-policy-7", expires: "2027-06-30"}

A provider's own claim (asserted) never satisfies a rule. Expired evidence stops counting. The engine checks that evidence is listed and unexpired; it does not verify an attestation cryptographically. See Core concepts.

opp validate acme.destinations.yaml

2. Start the service

export OPP_TOKEN="$(openssl rand -hex 24)"
opp-engine serve acme.opp.yaml --http 0.0.0.0:8765 \
    --destinations acme.destinations.yaml \
    --allow-purpose medical_analysis \
    --decision-log /var/log/opp/decisions.jsonl
  • On a network address the engine refuses to start without a bearer token in OPP_TOKEN.
  • --allow-purpose authorises a purpose for every caller of this instance. Per-caller identities are not implemented yet, so run one instance per trust domain.
  • --decision-log writes one line per decision, with counts per class and no content.
  • The engine reads the documents at start-up. Restart it after you change them.

In a container

git clone https://github.com/kannancet/open-privacy-protocol-engine && cd open-privacy-protocol-engine
docker build -t opp-engine .
docker run -d --name opp-engine -p 127.0.0.1:8765:8765 -e OPP_TOKEN \
  -v $PWD/../acme.opp.yaml:/model.opp.yaml:ro \
  -v $PWD/../acme.destinations.yaml:/destinations.yaml:ro \
  opp-engine --http 0.0.0.0:8765 --destinations /destinations.yaml

3. Call it from your code

# pip install open-privacy-protocol
from opp.client import EngineClient, obligations

engine = EngineClient("http://opp.internal:8765", token=OPP_TOKEN)
r = engine.check(text, destination="hosted-llm", mode="confidential", purpose="medical_analysis")
if r["verdict"] in ("block", "review"):
    raise PermissionError(r["summary"])
for duty in obligations(r):        # e.g. enforce_mode, check_output: fulfil each one
    ...
send(r["safe_content"])
// npm install open-privacy-protocol
import { EngineClient, mustEnforce } from "open-privacy-protocol";

const engine = new EngineClient("http://opp.internal:8765", { token: OPP_TOKEN });
const r = await engine.check(text, "hosted-llm", { mode: "confidential", purpose: "medical_analysis" });
if (r.verdict === "block" || r.verdict === "review") throw new Error(r.summary);
for (const duty of mustEnforce(r)) { /* fulfil each one */ }
await send(r.safe_content);
curl -s http://opp.internal:8765/v1/check -H "Authorization: Bearer $OPP_TOKEN" \
  -H "Content-Type: application/json" -d '{"content": "Summarise the oncology file.",
  "destination": "hosted-llm", "mode": "confidential", "purpose": "medical_analysis",
  "obligations_supported": true}'

Put the call where content leaves your systems, such as an LLM gateway, so an agent cannot skip it. Check answers and tool calls too, with "stage": "output" or "tool_call" and the destination they go to next.

Check that it worked

curl -s -H "Authorization: Bearer $OPP_TOKEN" http://127.0.0.1:8765/healthz

It returns {"ok": true, ...}, and a check from your code returns a decision with an id.

Keep it running

  • Change: edit the model or registry in a pull request, run opp validate in CI, merge, restart the engine.
  • Evidence: renew approvals and attestations before their expires date; expired evidence fails closed.
  • Audit: keep the decision log; each line has the decision id, destination, mode, rules and obligations.

You are done. Next: the full engine reference for every route, tool and field, and the specification if you build your own enforcement point.