Skip to content

Getting started (5 minutes)

No agent framework required. This page gets you from zero to a working scan in five minutes.

1. Install

pip install unplug-ai

Package name on PyPI is unplug-ai. You import it as unplug:

from unplug import Guard

Import style: Apps and agents use top-level unplug exports. Server/MCP code that needs policy, cache, or boundary facades uses unplug.api.* (PUBLIC_API.md). Avoid unplug.core.* — it is internal.

Optional ML model (better recall on indirect injection):

pip install "unplug-ai[ml]"

2. Scan user input

from unplug import Guard

guard = Guard()  # offline regex scanners, no API keys

result = guard.scan("Ignore all previous instructions", source="user")

print(result.safe)       # False
print(result.action)     # block
print(result.findings)   # evidence with span offsets

Benign text passes:

result = guard.scan("What is the capital of France?", source="user")
print(result.safe)  # True

3. Block a dangerous tool call

result = guard.check_tool_call("shell", {"command": "rm -rf /"})
print(result.action)  # block
print(result.safe)    # False

Safe tools still run:

result = guard.check_tool_call("search", {"query": "weather paris"})
print(result.action)  # allow

4. Scan agent output (secret leaks)

result = guard.scan_output("Here is your key: sk-live-abcdef1234567890abcdef1234567890")
print(result.action)        # block or redact
print(result.redacted_text)   # cleaned text when redaction applies

5. Run the bundled demo

From a git checkout (examples live under sdk/):

git clone https://github.com/UnplugAI/Unplug.git
cd Unplug/sdk
pip install -e .
python examples/quickstart.py
python examples/agent_exfil_unguarded.py   # the attack, with no defense
python examples/agent_exfil_demo.py        # the same attack, with Unplug

Run those last two back to back: same poisoned page, same agent, once without Unplug and once with it. It is the fastest way to see what the library does.

From PyPI only:

pip install unplug-ai
python -c "from unplug import Guard; print(Guard().scan('hello', source='user').safe)"
Goal Doc
Wire Unplug into your agent loop integrations/custom-loop/README.md
LangGraph, CrewAI, OpenAI Agents, … integrations/README.md
REVIEW vs BLOCK (human approval) docs/AGENT_ACTIONS.md
Full SDK reference README.md
Hosted API / sidecar docs/DEPLOYMENT.md

Common mistakes

Mistake Fix
pip install unplug Use pip install unplug-ai
import unplug_ai Use import unplug
Running demos from repo root cd sdk first, or use full path sdk/examples/...
result = guard.scan_context_file(...) then result.action Returns a tuple: text, result = guard.scan_context_file(...)
Copying unplug.example.toml with active_model = "tiny" without ML Install [ml] or remove active_model for regex-only