Quickstart

Govern your first AI agent in under 2 minutes.

Install

Shell
pip install phronedge

Get an API key

  1. 1.Sign up free at AI Constitutional Console
  2. 2.Go to API Keys in the console
  3. 3.Click Create Key
  4. 4.Copy the key (starts with pe_live_)

Set your API key

Shell
export PHRONEDGE_API_KEY=pe_live_your_key_here

Govern a single tool

Python
from phronedge import PhronEdge

pe = PhronEdge()

@pe.govern("lookup_patient")
def lookup_patient(patient_id):
    """Look up patient records from the claims database."""
    return db.query(f"SELECT * FROM patients WHERE id = {patient_id}")

# This call is now governed.
# 7 checkpoints run in under 50ms before the function executes.
result = lookup_patient("P-12345")
print(result)

Govern multiple tools on one agent

Python
pe = PhronEdge()

@pe.govern("search_claims")
def search_claims(query):
    return claims_db.search(query)

@pe.govern("approve_payout")
def approve_payout(claim_id, amount):
    return payments.process(claim_id, amount)

@pe.govern("flag_fraud")
def flag_fraud(claim_id, reason):
    return fraud_engine.flag(claim_id, reason)

# Every tool call is independently governed.
# search_claims may be allowed while approve_payout is blocked
# if the agent's clearance does not include financial operations.

Govern a multi-agent system

Python
pe = PhronEdge()

# Lead agent: can delegate to sub-agents
@pe.govern("orchestrate_investigation")
def orchestrate_investigation(case_id):
    # This agent coordinates. PhronEdge validates its credential
    # permits delegation to the sub-agents below.
    medical = review_medical_history(case_id)
    financial = check_financial_records(case_id)
    return compile_report(case_id, medical, financial)

# Sub-agent 1: medical data access (PII_HEALTH clearance required)
@pe.govern("review_medical_history")
def review_medical_history(case_id):
    return medical_db.get_history(case_id)

# Sub-agent 2: financial data access (PII_FINANCIAL clearance required)
@pe.govern("check_financial_records")
def check_financial_records(case_id):
    return finance_db.get_records(case_id)

# Sub-agent 3: report generation (no sensitive data access)
@pe.govern("compile_report")
def compile_report(case_id, medical, financial):
    return report_engine.generate(case_id, medical, financial)

# The lead agent calls orchestrate_investigation.
# PhronEdge validates:
#   1. Lead agent has delegation permission for sub-agents
#   2. Sub-agent 1 has PII_HEALTH clearance
#   3. Sub-agent 2 has PII_FINANCIAL clearance
#   4. Sub-agent 3 has no sensitive data in its output
# If any sub-agent exceeds its clearance, the entire chain is blocked.
result = orchestrate_investigation("CASE-7891")

What happens on every call

Your code calls a governed function
  |
  v
PhronEdge SDK intercepts before execution
  |
  v
Gateway runs 7 checkpoints in under 50ms:
  1. Credential validation   - ECDSA P-256 signature verification
  2. PII detection           - Input scanned for personal data
  3. Jurisdiction resolution - 196 jurisdictions mapped
  4. Behavioral analysis     - Baseline anomaly detection
  5. Tool permission         - Is this tool in the credential?
  6. Data classification     - Does agent clearance match data level?
  7. Output constraints      - Response scanned before return
  |
  v
ALLOW: function executes, result returned, event anchored
BLOCK: function never executes, regulation cited, event anchored

What a block looks like

Python
from phronedge import PhronEdge, GovernanceError

pe = PhronEdge(raise_on_block=True)

@pe.govern("access_medical_records")
def access_medical_records(patient_id):
    return db.query(f"SELECT * FROM medical_records WHERE patient = {patient_id}")

try:
    result = access_medical_records("P-12345")
except GovernanceError as e:
    print(e.checkpoint)   # "Data Classification"
    print(e.regulation)   # "GDPR Art. 9 Special Categories"
    print(e.reason)       # "Agent clearance PUB does not meet PII_HEALTH requirement"

What an allow looks like

Every allowed call is anchored to an immutable hash chain:

Python
result = search_claims("open claims Q4 2025")
# Result returned normally.
# In the console, you see:
#   Event: TOOL_CALL_ALLOWED
#   Agent: claims-investigator
#   Tool: search_claims
#   Checkpoint: All 7 passed
#   Hash: a7f3b2c9...
#   Prev Hash: d1e4f5a6...
#   Regulation: GDPR Art. 5(1)(f), EU AI Act Art. 9

Next steps

Next
SDK Reference