ShieldPi Watchtower — live agent monitoring SDK for Python
Project description
ShieldPi Python SDK
Official Python SDK for the ShieldPi LLM Security Scanner API.
Installation
pip install shieldpi
Quick Start
from shieldpi import ShieldPi
client = ShieldPi(api_key="your-api-key")
# Create a target
target = client.targets.create(
name="My Chatbot",
url="https://my-chatbot.com/api/chat",
scan_mode="api"
)
# Run a scan
scan = client.scans.create(target_id=target.id)
# Wait for completion
result = client.scans.wait(scan.id)
# Get the report
print(f"Security Grade: {result.grade}")
print(f"Score: {result.score}/100")
print(f"Findings: {result.total_findings}")
API Reference
Authentication
client = ShieldPi(api_key="sk-...", base_url="https://api.shieldpi.io/api")
Targets
client.targets.list()
client.targets.create(name="...", url="...", scan_mode="model")
client.targets.get(target_id)
client.targets.delete(target_id)
Scans
client.scans.create(target_id=target_id)
client.scans.get(scan_id)
client.scans.list()
client.scans.wait(scan_id, timeout=3600)
Reports
client.scans.download_report(scan_id, format="pdf")
client.scans.download_report(scan_id, format="json")
Live Agent Monitoring
For real-time agent monitoring, use the Monitor class:
from shieldpi import Monitor
monitor = Monitor(sdk_key="shpi_live_...")
with monitor.start_session(
agent_name="invoice-bot",
stated_goal="help users file invoices",
) as session:
session.log_user_message("How do I file a Q1 invoice?")
session.log_tool_call("search_docs", {"query": "Q1 invoice filing"})
session.log_tool_result("search_docs", {"results": [...]})
session.log_final_response("Here's how to file a Q1 invoice...")
LangChain Integration
from shieldpi import Monitor
from shieldpi.hooks.langchain import ShieldPiCallbackHandler
monitor = Monitor(sdk_key="shpi_live_...")
callbacks = [ShieldPiCallbackHandler(
monitor,
agent_name="my-agent",
stated_goal="help users with their accounts",
)]
agent.invoke({"input": "..."}, config={"callbacks": callbacks})
Anthropic Tool Use
from anthropic import Anthropic
from shieldpi import Monitor
from shieldpi.hooks.anthropic import monitored_tool_use
anth = Anthropic()
monitor = Monitor(sdk_key="shpi_live_...")
with monitored_tool_use(monitor, agent_name="invoice-bot") as session:
session.log_user_message("Help me file an invoice")
response = anth.messages.create(
model="claude-opus-4-20250514",
messages=[{"role": "user", "content": "Help me file an invoice"}],
tools=[...],
)
session.observe_anthropic_response(response)
Configuration
Environment variables:
SHIELDPI_API_KEY— API key for scanner operationsSHIELDPI_SDK_KEY— SDK key for live monitoringSHIELDPI_BASE_URL— Override the API base URL (default:https://api.shieldpi.io/api)
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shieldpi-0.1.0.tar.gz
(9.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
shieldpi-0.1.0-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file shieldpi-0.1.0.tar.gz.
File metadata
- Download URL: shieldpi-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
731e39af2ab96bcd0eb7c53895fd4af6dacc5756777100d6dc01062839e7cddf
|
|
| MD5 |
c46b372d417fae67a6516a4a822cfc55
|
|
| BLAKE2b-256 |
eed80a1e8658f14a71388e45faa6865f8cc5997052c332b8a6de2541cbb8e76f
|
File details
Details for the file shieldpi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: shieldpi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc81cac68448580fb9779899731f324906d374d03c1e435a8542f78f604ef83e
|
|
| MD5 |
a7c51fe1103d818478ed15c9127330e3
|
|
| BLAKE2b-256 |
7d0d8cbaa79f02d72d8641262711ce4e994dfd899ff259e079548be9f8d2ad63
|