LLM prompt injection firewall SDK
Project description
SentryML
The security layer every LLM-powered app is missing.
Real-time prompt injection firewall — scan user input before it reaches your LLM.
Install
pip install sentryml
Quickstart (3 lines)
import sentryml
sentryml.configure(api_key="your-key", api_url="https://sentryml-api-jihxilyyya-nw.a.run.app")
safe_prompt = sentryml.guard(user_message) # raises ThreatBlockedError if attack detected
Get an API key
Sign up free at https://nastwest-u26wck-618.web.app
10,000 scans/month. No credit card.
How it works
User Input → sentryml.guard() → SentryML API → BLOCK/ALLOW → Your LLM
Detects 8 attack types using semantic similarity (all-MiniLM-L6-v2) with token-level explainability.
Attack types detected
- prompt_injection, jailbreak, role_hijacking, data_exfiltration
- indirect_injection, goal_hijacking, context_manipulation
Full scan response
result = sentryml.scan('your prompt', app_id='my-chatbot')
print(result.severity) # critical / high / medium / low / safe
print(result.threat_score) # 0.0 – 1.0
print(result.attack_type) # prompt_injection / jailbreak / etc
print(result.recommended_action) # block / flag / allow
print(result.latency_ms) # scan latency
print(result.carbon_g_co2e) # CO2e grams per scan
print(result.token_explanations) # SHAP token attribution
print(result.threat_summary) # Gemini-generated narrative
Guard pattern (recommended)
from sentryml.exceptions import ThreatBlockedError
def chat(user_message: str) -> str:
try:
safe_prompt = sentryml.guard(user_message)
except ThreatBlockedError as e:
return f'Blocked: {e.result.attack_type} ({e.result.threat_score:.0%})'
return llm.complete(safe_prompt)
Async support
result = await sentryml.scan_async(user_message, app_id='my-app')
Carbon tracking
Every scan returns carbon_g_co2e. Blocked attacks save CO2 by preventing unnecessary LLM calls.
Track your AI security carbon footprint in the live dashboard.
Live dashboard
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
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
File details
Details for the file sentryml-0.1.2.tar.gz.
File metadata
- Download URL: sentryml-0.1.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f69530d08eca2438ff5a6c191d74a3646ad0460d44a570c87878644c28600bd7
|
|
| MD5 |
88399153aea80c004b0afa4fc5f2cdac
|
|
| BLAKE2b-256 |
ead3cdb86113102ed2eecfef56fec646706e2eb14473734cc4dd4b3b08b1b1bd
|
File details
Details for the file sentryml-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sentryml-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dca835ea27f2e31d4bdb48217fbaae51e290659bc293f7329c5bec394f228667
|
|
| MD5 |
593f6a3015a29cd8b442591f615bc305
|
|
| BLAKE2b-256 |
77a2c012774420bd55174c873de05960d9bb6931cc3cc02405d0849f2b583a94
|