Skip to main content

SENTINEL — Drop-in LLM Trust & Safety SDK. 19-agent parallel mesh: prompt injection, PII, jailbreak pattern detection, DAN attacks, cost anomaly detection, agentic loop breaking, hallucination, and compliance routing.

Project description

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

PyPI version Python 3.10+ License: MIT


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-ai-sdk

# Full gateway server with ML agents
pip install sentinel-ai-sdk[full]

# Server without ML (uses heuristic fallbacks)
pip install sentinel-ai-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.

Project 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.0.tar.gz (90.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentinel_guardrails_sdk-4.0.0-py3-none-any.whl (110.8 kB view details)

Uploaded Python 3

File details

Details for the file sentinel_guardrails_sdk-4.0.0.tar.gz.

File metadata

  • Download URL: sentinel_guardrails_sdk-4.0.0.tar.gz
  • Upload date:
  • Size: 90.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sentinel_guardrails_sdk-4.0.0.tar.gz
Algorithm Hash digest
SHA256 408c9fe73feccdc17b84335dcb81cd4a60aea41eb77bf888f1a917c9323b3bb8
MD5 384bd0873d670dfd545a3cab4e802710
BLAKE2b-256 8c363bfd87d715ecaca1abc27a1ff1e39965b12b2fd7d74fac85c6a50575731c

See more details on using hashes here.

File details

Details for the file sentinel_guardrails_sdk-4.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentinel_guardrails_sdk-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99e487818ad8a349f792da58f2c3a36d2943fb70bde2caddff0cb9216f469f5a
MD5 6a66ddd391f98ff7cdc0f9d9e770dc8b
BLAKE2b-256 ab4967f1e17657a055e395939c4e616887a13f878dc7c97a8c9a8ad71527a523

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page