{
 "schema_version": 1,
 "generated": "2026-10-23",
 "id": "respanai-respan-gateway--build-a-guardrail-or-pii-plugin",
 "repo": "respanai/respan-gateway",
 "repo_url": "https://github.com/respanai/respan-gateway",
 "repo_slug": "respanai-respan-gateway",
 "title": "Write a custom guardrail or PII masking plugin",
 "page_title": "How to write a custom guardrail or PII masking plugin with Respan Gateway",
 "summary": "Use the public plugin API to add masking or policy checks to every call.",
 "who": "A Rust developer on a platform team who must enforce a rule, such as masking personal data, on all model traffic.",
 "problem": "Model traffic may contain personal data or policy-breaking content that must be filtered before it leaves the company.",
 "outcome": "A custom plugin built on the gateway's one-trait, four-hook API runs on every request.",
 "steps": [
  "Read the plugin guide at docs/plugins.md.",
  "Open the examples index at examples/README.md and pick the example closest to your rule, such as guardrails or PII masking.",
  "Implement the plugin trait's four hooks in Rust, following the example.",
  "Build the gateway with your plugin mounted, using the embed option in docs/plugins.md, then run the check command against your config. (inferred, check the README)",
  "Send a request containing test personal data and confirm the masked output in the live log."
 ],
 "agent_prompt": "In the respan-gateway repo, read docs/plugins.md and examples/README.md, then write a Rust plugin that implements the four hooks for <rule>. Return the plugin file and the test request result, and verify that the masked value does not appear in the live log.",
 "agents": [
  "any"
 ],
 "difficulty": "Advanced",
 "time": "90 minutes",
 "basis": "readme",
 "caveat": "The README describes the plugin API only at a high level, so the exact hook names and signatures must be taken from docs/plugins.md rather than assumed.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "rust",
 "requirements": [
  "Python with pip, or a Rust toolchain with cargo, or Docker",
  "An API key for at least one model vendor, such as OPENAI_API_KEY",
  "An existing app or SDK that accepts a custom base URL",
  "Optional: a Respan API key for tracing and a tool vendor key for MCP tools"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.6,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/respanai-respan-gateway/build-a-guardrail-or-pii-plugin/",
 "md": "https://dedupedai.com/use-cases/respanai-respan-gateway/build-a-guardrail-or-pii-plugin/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/respanai-respan-gateway--build-a-guardrail-or-pii-plugin.json",
 "api_version": "v1"
}
