Add AI Governance to Your AI Agent in 5 Minutes
A hands-on tutorial: install the SDK, add PII redaction, enforce policies, and integrate with LangChain — all in under 5 minutes.
February 12, 2026 · 6 min read · Tork Network
“Your AI agent just leaked a customer's Social Security number to a third-party API.”
That's not a hypothetical. It happened last month to a production agent with no governance layer. The fix took 30 seconds — adding one middleware call. The cleanup took three weeks.
This tutorial walks you through adding real governance to your AI agent. Not a toy demo — actual PII redaction, policy enforcement, and compliance receipts that hold up under audit. You'll be done before your coffee gets cold.
Prerequisites
- A Tork account (free tier — 5,000 calls/month, no credit card)
- Your API key from the dashboard (starts with
tork_jwt_ortork_live_) - Python 3.8+ or Node.js 18+
Step 1: Install the SDK
Pick your language:
Set your API key as an environment variable:
Step 2: Add PII Redaction
The most common governance failure is PII leakage — user data passing through to LLMs, logs, or third-party APIs unredacted. Tork detects 50+ PII types across 13 regional formats and redacts them before they leave your system.
Python
JavaScript
The governed field always contains the redacted version. The original is never logged or stored by Tork — redaction happens in-memory.
Step 3: Enforce Policies
PII redaction keeps data safe. Policy enforcement keeps your agent safe. Define what your agent is — and isn't — allowed to do:
Python
JavaScript
Policies can be strict (block on any violation), standard (warn and log), or minimal (log only). You can also block specific tool calls:
Step 4: Govern Both Input and Output
Governing input catches prompt injection and PII in user messages. But LLMs can also hallucinate PII or leak training data in their responses. Govern both directions:
Python
JavaScript
Step 5: Integrate with LangChain
If you're using LangChain (or CrewAI, AutoGen, or any of the 116 supported frameworks), Tork plugs in as a callback or middleware — no refactoring required:
Python (LangChain)
JavaScript (LangChain.js)
The callback intercepts every LLM call, governs input and output, and writes a compliance receipt — zero changes to your existing chain logic.
Step 6: Verify in the Dashboard
Run your agent and head to the Tork dashboard. You'll see:
- API call history — every govern call with timestamps, latency, and action taken
- PII detections — types found, redaction counts, and trends over time
- Policy violations — blocked and flagged requests with full context
- Compliance receipts — HMAC hash-chained, blockchain-verified audit trail for every decision
- TORKING-X score — your 0–100 governance maturity rating across nine dimensions
Compliance receipts are the part auditors care about. Each receipt is cryptographically chained to the previous one, so tampering with any single entry invalidates the entire chain. Hand these to your compliance team for HIPAA, GDPR, SOC 2, or PCI-DSS reporting.
What You Just Built
In under 5 minutes, you added:
- PII redaction for 50+ data types across 13 regional formats
- Policy enforcement with block, flag, and allow actions
- Bidirectional governance on both user input and LLM output
- Framework integration via LangChain callbacks (or any of 116 adapters)
- Tamper-proof compliance receipts for audit and regulatory reporting
All at ~20ms per call. Your agent is now governed, auditable, and compliant — without a single architectural change.
Next Steps
- Read the full documentation for advanced policy configuration, custom rules, and the complete API reference
- Explore MCP Security if your agent uses the Model Context Protocol
- Try Human-in-the-Loop for high-stakes actions like payments and database writes
- Check out Tork Guardian for OpenClaw if you're building with OpenClaw skills
- See pricing plans for higher limits, custom policies, SSO, and dedicated support
Ready to govern your agent?
Free tier includes 5,000 API calls per month. No credit card required.
Get Your API KeyTork Network Pty Ltd — Sydney, Australia