SENTINEL — LLM Trust & Safety Infrastructure Layer
Production-grade security middleware for enterprise AI deployments. Drop-in SDK · 19-agent parallel mesh · <72ms P99 · HIPAA/GDPR/SOC2/DPDP
Quick Start (3 lines)
import openai, sentinel
client = sentinel.wrap(
openai.OpenAI(api_key="sk-..."),
tenant_id="my-org",
api_key="sk-sentinel-...",
)
# All existing code works unchanged:
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Help me with this contract."}],
)
Architecture
SDK (wrap) → FastAPI Gateway → 19-Agent Parallel Mesh → Risk Aggregator → Circuit Breaker → LLM API
↓ ↓ ↓
Postgres Redis FAISS Index Kafka
(audit trail) (policy cache) (attack vectors) (event stream)
The 19-Agent Mesh
v1 Core (7 agents)
| # | Agent | Technique | What it catches |
|---|---|---|---|
| 1 | InjectionScout | FAISS ANN + regex | Prompt injection, delimiter attacks |
| 2 | PIISentinel | SpaCy NER + regex | PHI/PII leakage (HIPAA, GDPR, DPDP) |
| 3 | JailbreakGuard | Sliding window | Multi-turn escalation, persona attacks |
| 4 | ToxicityScreener | HF Detoxify | Toxicity, threats, hate speech |
| 5 | HallucinationProbe | DeBERTa NLI | Ungrounded factual claims in RAG |
| 6 | ContextAnchor | Cosine similarity | Semantic context drift |
| 7 | ComplianceTagger | Rule-based | HIPAA/GDPR/SOC2/PCI-DSS/DPDP tagging |
v2 Enterprise (5 agents)
| # | Agent | Technique | What it catches |
|---|---|---|---|
| 8 | ResponseSafetyLayer | Pattern scan | Harmful LLM output, data leakage |
| 9 | MultilingualGuard | Multilingual embeddings | Cross-language jailbreaks |
| 10 | ToolCallSafety | Schema validation | Dangerous function calls |
| 11 | BrandGuard | Sentiment + patterns | Unauthorized promises, brand damage |
| 12 | TokenAnomalyDetector | Statistical analysis | Encoding attacks, token smuggling |
v3 Advanced (3 agents)
| # | Agent | Technique | What it catches |
|---|---|---|---|
| 13 | PromptLineage | Session memory graph | Multi-turn escalation trajectories |
| 14 | IntentClassifier | DeBERTa zero-shot | Malicious intent classification |
| 15 | AdversarialRephrasing | Heuristic perturbation | Evasion via paraphrasing |
v4 Production (4 agents)
| # | Agent | Technique | What it catches |
|---|---|---|---|
| 16 | JailbreakPatternDetector | DAN/roleplay patterns | DAN attacks, character bypass, social engineering |
| 17 | LocaleComplianceRouter | Locale-aware rules | Language-specific regulatory routing (DPDP, GDPR) |
| 18 | CostAnomalyDetector | Spend-rate analysis | Runaway token costs, inference bombs |
| 19 | AgenticLoopBreaker | Loop detection | Infinite tool-call loops in agentic frameworks |
ML Models Used
| Component | Model | Size | Purpose |
|---|---|---|---|
| ML Risk Scorer | ProtectAI/deberta-v3-base-prompt-injection-v2 |
~180MB | Primary injection detection |
| Intent Classifier | MoritzLaurer/deberta-v3-base-zeroshot-v2.0 |
~440MB | Zero-shot intent classification |
| Hallucination Probe | cross-encoder/nli-deberta-v3-small |
~170MB | NLI grounding verification |
| Embedding | sentence-transformers/all-MiniLM-L6-v2 |
~80MB | FAISS + cosine similarity |
| Toxicity | detoxify/original |
~450MB | Multi-dimension toxicity scoring |
| PII | en_core_web_sm (SpaCy) |
~12MB | Named entity recognition |
Install
# SDK only (lightweight, for client-side integration)
pip install sentinel-guardrails-sdk
# Full gateway server with ML agents
pip install sentinel-guardrails-sdk[full]
# Server without ML (uses heuristic fallbacks)
pip install sentinel-guardrails-sdk[server]
Free vs Pro Tiers
| Feature | Free | Pro (₹4,500/mo) |
|---|---|---|
screen() — threat detection |
✅ | ✅ |
trust_score() — risk scoring |
✅ | ✅ |
wrap() — OpenAI/Claude proxy |
✅ | ✅ |
| All 19 agents | ✅ | ✅ |
analytics() — dashboard data |
❌ | ✅ |
compliance_export() — audit CSV/PDF |
❌ | ✅ |
configure_agents() — live tuning |
❌ | ✅ |
audit_log() — full event log |
❌ | ✅ |
Multi-Language Integration
Sentinel's gateway exposes a standard REST API, making it accessible from any language:
Node.js / TypeScript
const response = await fetch('https://gateway.sentinel-ai.dev/v1/screen', {
method: 'POST',
headers: {
'Authorization': 'Bearer sntnl-your-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
messages: [{ role: 'user', content: 'Check this prompt' }],
tenant_id: 'my-org',
}),
});
const result = await response.json();
Java
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://gateway.sentinel-ai.dev/v1/screen"))
.header("Authorization", "Bearer sntnl-your-key")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
React (Frontend)
const screenPrompt = async (userMessage) => {
const res = await fetch('/api/sentinel/screen', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ messages: [{ role: 'user', content: userMessage }] }),
});
return res.json();
};
Deploy with Docker
# Full stack (Postgres + Redis + Kafka + Gateway + Dashboard)
cp .env.example .env # set SECRET_KEY and OPENAI_API_KEY
docker compose up --build -d
curl http://localhost:8000/health
# Lightweight dev (just Postgres + Redis)
docker compose -f docker-compose.dev.yml up -d
python -m uvicorn sentinel.gateway.main:app --reload
Run Locally (Development)
# 1. Start database + cache
docker compose -f docker-compose.dev.yml up -d
# 2. Install dependencies
pip install -e ".[full,dev]"
python -m spacy download en_core_web_sm
# 3. Start gateway
cp .env.example .env
python -m uvicorn sentinel.gateway.main:app --reload --port 8000
# 4. Start dashboard (optional)
cd dashboard && npm install && npm run dev
Run Benchmark
python tests/red_team/run_benchmark.py
Expected results:
- Detection rate: 91% (v4 upgrade from 87%)
- False positive rate: 1.8%
- P99 latency: <72ms
SDK Integration Options
# Option 1: OpenAI wrapper (zero code changes)
client = sentinel.wrap(openai_client, tenant_id="...", api_key="...")
# Option 2: LangChain callback
from sentinel.sdk.langchain_handler import SentinelCallbackHandler
handler = SentinelCallbackHandler(tenant_id="...", api_key="...")
llm = ChatOpenAI(callbacks=[handler])
# Option 3: LlamaIndex node postprocessor
from sentinel.sdk.llamaindex_node import SentinelNodePostprocessor
postprocessor = SentinelNodePostprocessor(tenant_id="...", api_key="...")
query_engine = index.as_query_engine(node_postprocessors=[postprocessor])
API Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /auth/register |
Create tenant |
| POST | /auth/token |
Issue JWT |
| POST | /v1/chat |
Intercepted chat (full pipeline) |
| POST | /v1/screen |
Screen-only (no LLM call) |
| POST | /v1/trust-score |
Trust score API (0–100) |
| GET | /v1/audit |
Paginated audit log |
| GET | /v1/analytics |
24h threat analytics |
| PUT | /admin/policy/{id} |
Live policy update |
| GET | /health |
Liveness probe |
| GET | /readiness |
Deep readiness check |
| WS | /ws/dashboard |
Real-time event stream |
License
MIT — See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sentinel_guardrails_sdk-4.0.1.tar.gz
(103.1 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
File details
Details for the file sentinel_guardrails_sdk-4.0.1.tar.gz.
File metadata
- Download URL: sentinel_guardrails_sdk-4.0.1.tar.gz
- Upload date:
- Size: 103.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
287065c98c7d18fa64544de82b30054ed95c119609bdbd3a55e25279575cdb1f
|
|
| MD5 |
1c9a8ff1173eb3a3c0cd4f01a22dd82f
|
|
| BLAKE2b-256 |
a404380367e2cf62d638c22e1b8e5570cb62b39849d622f1eb831be4f626a8ca
|
File details
Details for the file sentinel_guardrails_sdk-4.0.1-py3-none-any.whl.
File metadata
- Download URL: sentinel_guardrails_sdk-4.0.1-py3-none-any.whl
- Upload date:
- Size: 125.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8faf2e6884f0eb391407142c350b556762c1709ca83e04c0348fc1beaf2a821
|
|
| MD5 |
2c8c4c3fcf8683db037206411430bb17
|
|
| BLAKE2b-256 |
d6f375ee6fd33f4afe9f846152d53f73bccbb3b4c50a6416e9c937572d2525f0
|