Powered by Prime β the compliance gate agent that intercepts every AI query,
detects regulated data in real-time, and routes only to approved models.
Quick Start β’ Architecture β’ How It Works β’ API Reference β’ Demo Scenarios
Application : https://sentinal-ai-a8ig.onrender.com/
Production AI systems regularly handle sensitive data β patient records, financial information, and personally identifiable information. Most AI pipelines send this data directly to third-party models with:
- β No compliance checks
- β No audit trail
- β No memory of past violations
- β No control over which models access your data
This creates regulatory risk under HIPAA, GDPR, PCI-DSS, and other frameworks.
Sentinel AI places an intelligent compliance gate between your application and AI models. Every query is scanned for regulated data, every decision is logged to an immutable audit trail, and only policy-approved models ever receive your data. Prime β the core agent β remembers past decisions across sessions using Hindsight, enabling adaptive enforcement that learns from your organization's compliance patterns over time.
flowchart TB
subgraph Client["π₯οΈ Client Application"]
A["AI Query<br/><i>e.g., Patient records,<br/>Medical questions</i>"]
end
subgraph SentinelAI["π‘οΈ Sentinel AI β Prime Compliance Gate"]
direction TB
B["π PHI Detector<br/><i>Regex + LLM<br/>Two-Pass Scan</i>"]
C{"π¦ Compliance Gate<br/><i>ALLOW / REDACT / BLOCK</i>"}
D["π§ Hindsight Memory<br/><i>Cross-Session Recall<br/>Pattern Recognition</i>"]
E["π Cascade Router<br/><i>Cost-Optimized<br/>Model Selection</i>"]
F["βοΈ Redactor<br/><i>Type-Annotated<br/>PHI Masking</i>"]
G["π Audit Logger<br/><i>Append-Only JSONL<br/>Immutable Trail</i>"]
end
subgraph Models["β
Approved Models"]
H["Groq<br/><code>openai-gpt-oss-120b</code>"]
I["Ollama<br/><code>llama3.1</code>"]
end
subgraph Blocked["π« Blocked Models"]
J["OpenAI GPT-4"]
K["Anthropic Claude"]
end
A -->|"POST /query"| B
B --> C
D <-.->|"Recall & Store"| C
C -->|"ALLOW"| E
C -->|"REDACT"| F
F --> E
C -->|"BLOCK"| G
E --> H
E -.->|"Escalate"| I
E --> G
H --> G
C -.-x J
C -.-x K
style SentinelAI fill:#0a0f1a,stroke:#00d4ff,stroke-width:2px,color:#e0e0e0
style Client fill:#1a1a2e,stroke:#ff6b35,stroke-width:2px,color:#e0e0e0
style Models fill:#0d2818,stroke:#00e676,stroke-width:2px,color:#e0e0e0
style Blocked fill:#2d0a0a,stroke:#ff4444,stroke-width:2px,color:#e0e0e0
sequenceDiagram
participant Client
participant Prime as π‘οΈ Prime Agent
participant Detector as π PHI Detector
participant Memory as π§ Hindsight
participant Gate as π¦ Gate
participant Router as π Router
participant Audit as π Audit Log
Client->>Prime: POST /query { query, client_id }
Note over Prime: Step 1 β Log Query Received
Prime->>Audit: log_event("QUERY_RECEIVED")
Note over Prime: Step 2 β Detect PHI
Prime->>Detector: detect_phi(query)
Detector-->>Prime: { entities, confidence, method }
Note over Prime: Step 3 β Recall Memory
Prime->>Memory: recall_rules(client_id)
Memory-->>Prime: past_decisions[]
Note over Prime: Step 4 β Evaluate Policy
Prime->>Gate: evaluate(detection, policy, recall)
Gate-->>Prime: { decision: ALLOW|REDACT|BLOCK }
Note over Prime: Step 5 β Route or Block
alt BLOCK
Prime->>Audit: log_event("DECISION_MADE", BLOCK)
else REDACT
Prime->>Router: route(redacted_query, approved_models)
Router-->>Prime: { response, model_used, cost }
else ALLOW
Prime->>Router: route(query, approved_models)
Router-->>Prime: { response, model_used, cost }
end
Note over Prime: Step 6 β Persist Memory
Prime->>Memory: store_decision(client_id, decision)
Prime->>Audit: log_event("DECISION_MADE")
Prime-->>Client: { decision, response, audit_id, ... }
flowchart LR
subgraph Input
Q["Raw Query Text"]
end
subgraph Pass1["Pass 1 β Regex Engine"]
R1["SSN Pattern<br/><code>XXX-XX-XXXX</code>"]
R2["Phone Pattern<br/><code>(XXX) XXX-XXXX</code>"]
R3["Email Pattern<br/><code>user@domain.com</code>"]
R4["DOB Pattern<br/><code>MM/DD/YYYY</code>"]
R5["Medical Records<br/><code>MRN#XXXXX</code>"]
R6["Contextual Keywords<br/><code>Patient, Dr., Diagnosis</code>"]
end
subgraph Pass2["Pass 2 β LLM Verification"]
L["cascadeflow<br/>Contextual PHI<br/>Analysis"]
end
subgraph Output
O["PHI Entity List<br/><i>type, value, position,<br/>confidence, method</i>"]
end
Q --> R1 & R2 & R3 & R4 & R5 & R6
R1 & R2 & R3 & R4 & R5 & R6 --> L
L --> O
style Pass1 fill:#1a1a2e,stroke:#00d4ff,stroke-width:1px,color:#e0e0e0
style Pass2 fill:#1a1a2e,stroke:#ff6b35,stroke-width:1px,color:#e0e0e0
flowchart TD
A["Incoming Query"] --> B{"Requested model<br/>in blocked list?"}
B -->|"Yes"| BLOCK1["π« BLOCK<br/><i>Non-compliant model</i>"]
B -->|"No"| C{"PHI detected?"}
C -->|"No"| ALLOW["β
ALLOW<br/><i>Route to approved model</i>"]
C -->|"Yes"| D{"Contains high-sensitivity<br/>PHI? (SSN, MRN, etc.)"}
D -->|"Yes"| BLOCK2["π« BLOCK<br/><i>High-sensitivity data</i>"]
D -->|"No"| E{"Client has prior<br/>BLOCK history?"}
E -->|"Yes + High Confidence"| BLOCK3["π« BLOCK<br/><i>Repeat offender escalation</i>"]
E -->|"No"| REDACT["βοΈ REDACT<br/><i>Mask PHI β Route</i>"]
style BLOCK1 fill:#4a0000,stroke:#ff4444,color:#ffffff
style BLOCK2 fill:#4a0000,stroke:#ff4444,color:#ffffff
style BLOCK3 fill:#4a0000,stroke:#ff4444,color:#ffffff
style ALLOW fill:#003d00,stroke:#00e676,color:#ffffff
style REDACT fill:#3d3000,stroke:#ffab00,color:#ffffff
| Requirement | Version |
|---|---|
| Python | β₯ 3.11 |
| pip | Latest |
| Git | Latest |
git clone https://github.com/YOUR_USERNAME/sentinel-ai.git
cd sentinel-aipip install -r requirements.txtcp .env.example .envEdit .env with your API keys:
# Required β LLM Provider
GROQ_API_KEY=your_groq_api_key_here
# Optional β Cross-Session Memory
HINDSIGHT_API_KEY=your_hindsight_api_key_here
HINDSIGHT_BASE_URL=https://api.hindsight.vectorize.io
# Optional β Local Fallback Model
OLLAMA_BASE_URL=http://localhost:11434/v1Note: Sentinel AI works without any API keys β it gracefully degrades to simulated responses for LLM routing and in-memory storage for Hindsight. This is perfect for development and testing.
uvicorn sentinel_ai.main:app --reload --port 8000Or with Docker:
docker-compose upVisit http://localhost:8000 in your browser to access the interactive Prime Dashboard.
| Resource | URL |
|---|---|
| π₯οΈ Dashboard UI | http://localhost:8000 |
| β€οΈ Health Check | http://localhost:8000/health |
| π¬ Demo Scenarios | http://localhost:8000/demo |
| Integration | Purpose | Fallback |
|---|---|---|
| Hindsight | Persistent cross-session memory for compliance decisions | In-memory store (no cross-session persistence) |
| cascadeflow | Intelligent model routing with automatic escalation | Simulated responses with routing decision explanation |
| Groq | Ultra-fast inference for approved LLM models | Offline mode with compliance-only operation |
flowchart LR
subgraph Cycle["Memory Lifecycle"]
direction LR
S["π Store<br/><i>After every decision,<br/>persist query hash,<br/>client ID, outcome</i>"]
R["π Recall<br/><i>Before evaluation,<br/>fetch top-5 similar<br/>past decisions</i>"]
RF["π§ͺ Reflect<br/><i>Analyze trends,<br/>block rates, violation<br/>types over time</i>"]
end
S --> R --> RF --> S
style Cycle fill:#0a0f1a,stroke:#00d4ff,stroke-width:1px,color:#e0e0e0
- Store β After every compliance decision, Prime stores the query hash, decision type, client ID, and outcome metadata in Hindsight's vector store.
- Recall β Before evaluating a new query, Prime recalls the top-5 most relevant past decisions for the same client, enabling escalation for repeat offenders and pattern recognition.
- Reflect β The
reflect()method analyzes accumulated decisions to surface trends β block rates, common violation types, and compliance improvements over time.
- Policy Enforcement β Only models listed in
approved_modelsare available. Blocked models are never called. - Cost Optimization β Queries route to the cheapest approved model first (
groq/openai-gpt-oss-120b). - Automatic Escalation β If the primary model returns an empty or low-quality response, cascadeflow escalates to the fallback model (
ollama/llama3.1). - Redaction Pipeline β For REDACT decisions, PHI is masked with typed placeholders (
[REDACTED-SSN],[REDACTED-DIAGNOSIS]) before any model sees the data.
Sentinel AI ships with three built-in scenarios that exercise the Prime compliance gate across different risk levels.
python -m sentinel_ai.scenarioscurl http://localhost:8000/demoInput:
Patient John Smith (SSN: 123-45-6789) was diagnosed with Type 2 Diabetes
on 03/15/2024. His treating physician Dr. Sarah Johnson prescribed
Metformin 500mg twice daily.
| Field | Value |
|---|---|
| PHI Detected | β Yes (10 entities) |
| Decision | π« BLOCK |
| Reason | Query contains high-sensitivity PHI (SSN) |
| Model Used | none |
Input:
Dr. Emily Chen noted that the patient presents with symptoms consistent
with Major Depressive Disorder. The patient has been experiencing fatigue,
loss of appetite, and insomnia for the past three months.
| Field | Value |
|---|---|
| PHI Detected | β Yes (3 entities) |
| Decision | βοΈ REDACT |
| Reason | PHI eligible for redaction; mask strategy applied |
| Model Used | groq/openai-gpt-oss-120b |
Input:
What are the common side effects of Lisinopril?
With requested_model: "openai/gpt-4" (blocked model)
| Field | Value |
|---|---|
| Decision | π« BLOCK |
| Reason | Requested model 'openai/gpt-4' is not approved under HIPAA |
| Blocked Model | openai/gpt-4 |
| Method | Endpoint | Description |
|---|---|---|
POST |
/query |
Process a query through the Prime compliance gate |
POST |
/chat |
Send a message to the Support FAQ agent |
GET |
/demo |
Run all 3 demo scenarios |
GET |
/health |
System health check |
GET |
/ |
Interactive Prime Dashboard UI |
| Method | Endpoint | Description |
|---|---|---|
GET |
/audit/recent?limit=20 |
Get recent audit log entries |
GET |
/audit/client/{client_id} |
Get audit entries for a specific client |
GET |
/audit/stats |
Get aggregate audit statistics |
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{
"client_id": "my-app-001",
"query": "What are the side effects of Metformin?",
"requested_model": "groq/openai-gpt-oss-120b"
}'Response:
{
"decision": "ALLOW",
"reason": "No protected health information detected in the query.",
"response": "Metformin side effects include...",
"model_used": "groq/openai-gpt-oss-120b",
"cost": 0.001,
"latency_ms": 245.67,
"audit_id": "f5038df1-3a08-4f9b-9988-f95cf0bb0fde",
"phi_detected": false,
"entity_count": 0,
"detection_method": "regex",
"redacted": false,
"escalated": false
}Every compliance decision is logged to an append-only JSONL file (audit.log). Entries are never overwritten or deleted.
{
"audit_id": "f5038df1-3a08-4f9b-9988-f95cf0bb0fde",
"timestamp": "2025-01-15T10:30:00.150000+00:00",
"event": "DECISION_MADE",
"agent": "Prime",
"project": "Sentinel AI",
"client_id": "hospital-emr-001",
"query_hash": "98ac1f09b938...",
"decision": "BLOCK",
"reason": "Query contains high-sensitivity PHI (ssn).",
"model_used": "none",
"cost": 0.0,
"latency_ms": 7.84,
"entity_count": 10,
"redacted": false
}| Output | Details |
|---|---|
| File | audit.log in project root (configurable via AUDIT_LOG_PATH) |
| stdout | All entries printed to stdout for live monitoring |
| API | Query via /audit/recent, /audit/client/{id}, /audit/stats |
| Sample | See examples/sample_audit_log.jsonl |
sentinel-ai/
βββ π README.md β You are here
βββ π pyproject.toml β Package config, dependencies, metadata
βββ π requirements.txt β Pinned dependency versions
βββ π Dockerfile β Multi-stage production container
βββ π docker-compose.yml β One-command deployment
βββ π .env.example β Environment variable template
βββ π .gitignore β Git exclusion rules
β
βββ π sentinel_ai/ β Core Python package
β βββ __init__.py β Package metadata (version, agent name)
β βββ main.py β FastAPI application & all REST endpoints
β βββ prime.py β Prime agent β orchestrates full pipeline
β βββ detector.py β PHI/PII detection (regex + LLM two-pass)
β βββ gate.py β Compliance decision engine (ALLOW/REDACT/BLOCK)
β βββ router.py β Model routing via cascadeflow
β βββ memory.py β Hindsight memory integration + fallback store
β βββ audit.py β Append-only JSONL audit logger
β βββ redact.py β PHI redaction with typed placeholders
β βββ scenarios.py β Built-in demo scenarios (3 test cases)
β βββ config.py β Configuration loader (env + policy file)
β
βββ π policies/ β Compliance policy definitions
β βββ hipaa.json β HIPAA policy (PHI types, approved models, thresholds)
β
βββ π static/ β Frontend assets
β βββ index.html β Interactive Prime Dashboard (single-page app)
β
βββ π tests/ β Test suite (pytest)
β βββ test_detector.py β PHI detection tests
β βββ test_gate.py β Gate decision logic tests
β βββ test_router.py β Model routing tests
β βββ test_e2e.py β End-to-end integration tests
β
βββ π examples/ β Sample data for reference
βββ sample_audit_log.jsonl β Example audit log entries
βββ sample_query_allowed.json β Example allowed query payload
βββ sample_query_blocked.json β Example blocked query payload
Run the full test suite:
pytest -vRun specific test modules:
# PHI detection tests
pytest tests/test_detector.py -v
# Gate decision logic tests
pytest tests/test_gate.py -v
# Model routing tests
pytest tests/test_router.py -v
# End-to-end integration tests
pytest tests/test_e2e.py -vdocker-compose up --build- Multi-stage build for minimal image size
- Non-root user (
sentinel) for security - Health checks every 30 seconds
- Volume mounts for
audit.logpersistence and policy files - Environment injection via
.envfile
| Variable | Default | Description |
|---|---|---|
GROQ_API_KEY |
β | Groq API key for LLM inference |
HINDSIGHT_API_KEY |
β | Hindsight API key for cross-session memory |
HINDSIGHT_BASE_URL |
https://api.hindsight.vectorize.io |
Hindsight server URL |
HINDSIGHT_BANK_ID |
client_id |
Memory bank identifier |
HINDSIGHT_ENABLED |
true |
Enable/disable Hindsight integration |
OLLAMA_BASE_URL |
http://localhost:11434/v1 |
Ollama server URL for fallback model |
POLICY_FILE |
policies/hipaa.json |
Path to compliance policy file |
AUDIT_LOG_PATH |
audit.log |
Path to the audit log file |
LOG_LEVEL |
INFO |
Logging verbosity |
HOST |
0.0.0.0 |
Server bind address |
PORT |
8000 |
Server port |
- Multi-framework support β Add GDPR, SOC 2, and PCI-DSS policy templates
- Webhook alerts β Notify security teams on BLOCK decisions
- Client-specific policies β Per-client policy overrides
- Model quality scoring β Track and compare model response quality
- Batch processing β Support for bulk query compliance checking
- Advanced PHI detection β Fine-tuned NER model for medical entities
- Rate limiting β Per-client query rate limits with compliance tiers
- RBAC β Role-based access control for API endpoints
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m "Add my feature" - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
This project is licensed under the MIT License. See LICENSE for details.
Sentinel AI β Because compliance shouldn't be an afterthought.
Powered by Prime, the compliance gate agent.