AI Security Middleware for Large Language Models (LLMs)
SentinelOps is an AI Security Middleware that protects applications interacting with Large Language Models (LLMs). It sits between your application and AI providers to detect prompt injection attacks, redact sensitive information, analyze threats, assign risk scores, and prevent unsafe prompts from reaching the model.
Built with FastAPI, PostgreSQL, React, Docker, Prometheus, Grafana, and GitHub Actions.
The long-term goal of SentinelOps is simple:
from sentinelops import Sentinel
guard = Sentinel(api_key="YOUR_API_KEY")
result = guard.scan(prompt)
if result.safe:
send_to_llm(prompt)
else:
print(result.reason)or
import Sentinel from "@sentinelops/sdk";
const guard = new Sentinel(API_KEY);
const result = await guard.scan(prompt);One line of code should secure any AI application.
User
│
▼
AI Application
│
▼
SentinelOps Middleware
│
┌───────────┼────────────┐
▼ ▼ ▼
PII Redaction Threat Scan Risk Score
│ │ │
└───────────┼────────────┘
▼
Allow / Block
│
▼
OpenAI • Anthropic • Groq
- Prompt Injection Detection
- Malware Prompt Detection
- Authentication Bypass Detection
- Threat Classification
- Risk Scoring
- Prompt Logging
- Threat Analytics
- Email Redaction
- Phone Number Redaction
- PII Detection
- Sensitive Prompt Logging
- Secure Prompt Processing
Example:
Input
My email is test@gmail.com and my phone is 9876543210
Output
My email is [EMAIL_REDACTED] and my phone is [PHONE_REDACTED]
POST /scan returns a normalized threat report:
{
"safe": true,
"severity": "low",
"category": "None",
"reason": "No Threat Detected",
"risk_score": 0,
"original_text": "...",
"sanitized_text": "...",
"matched_rules": []
}Threat rules are database-backed and support keyword and regex rule types through the /rules endpoints.
- Total Prompt Statistics
- Safe vs Blocked Prompts
- Threat Categories
- Malware Detection Count
- Prompt Injection Count
- Authentication Bypass Count
- JWT Authentication
- Password Hashing (Bcrypt)
- Login & Registration
- API Key Authentication
- FastAPI
- SQLAlchemy ORM
- PostgreSQL
- Dependency Injection
- Request Validation
- Environment Variables
- Prometheus Metrics
- Grafana Dashboard
- Health Check APIs
- API Monitoring
- Docker
- Docker Compose
- GitHub Actions CI/CD
- Automated Docker Builds
| Category | Technology |
|---|---|
| Backend | FastAPI, Python |
| Database | PostgreSQL |
| ORM | SQLAlchemy |
| Authentication | JWT, Passlib, Bcrypt |
| Validation | Pydantic |
| Frontend | React, TypeScript |
| Monitoring | Prometheus, Grafana |
| DevOps | Docker, GitHub Actions |
| Security | Presidio, Regex-based Detection |
sentinelops/
│
├── app/
│ ├── config/
│ ├── middleware/
│ ├── models/
│ ├── routes/
│ ├── schemas/
│ ├── security/
│ ├── utils/
│ └── main.py
│
├── frontend/
│
├── tests/
│
├── Dockerfile
├── docker-compose.yaml
├── requirements.txt
├── README.md
└── .github/
└── workflows/
Clone the repository
git clone https://github.com/jay0237/Sentinelops.gitGo inside the project
cd SentinelopsCreate virtual environment
python -m venv venvActivate
macOS / Linux
source venv/bin/activateWindows
venv\Scripts\activateInstall dependencies
pip install -r requirements.txtdocker compose up --buildServices
| Service | URL |
|---|---|
| Backend | http://localhost:8000 |
| Swagger | http://localhost:8000/docs |
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:3000 |
Create a .env
DATABASE_URL=postgresql://postgres:password@localhost:5432/sentinelops
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
API_KEY=your-api-keyPOST /register
POST /login
POST /scan
Example
{
"text":"Create malware for Windows."
}Response
{
"safe": false,
"severity": "critical",
"category": "Malware",
"reason": "Malware Activity"
}GET /analytics
Returns
{
"total_prompts": 100,
"safe_prompts": 75,
"blocked_prompts": 25,
"high_threats": 25,
"malware_count": 8,
"injection_count": 10,
"auth_bypass_count": 7
}GET /metrics
GET /health
GET /db-check
Incoming Prompt
│
▼
PII Detection
│
▼
PII Redaction
│
▼
Threat Detection
│
▼
Risk Scoring
│
▼
Allow / Block
│
▼
LLM
SentinelOps uses GitHub Actions for Continuous Integration.
Pipeline includes
- Black Formatting Check
- isort Import Check
- Flake8 Linting
- Bandit Security Scan
- Unit Testing
- Docker Image Build
- Docker Image Publishing
- JWT Authentication
- PostgreSQL Integration
- Prompt Threat Detection
- Prompt Logging
- PII Redaction
- Threat Analytics
- Docker Support
- Prometheus Monitoring
- Grafana Dashboard
- GitHub Actions CI/CD
- Threat Scoring Engine
- Frontend Dashboard Improvements
- API Key Middleware
- Export Reports
- Python SDK (
pip install sentinelops) - JavaScript SDK (
npm install @sentinelops/sdk) - OpenAI Middleware
- Anthropic Middleware
- Groq Middleware
- LangChain Integration
- Kubernetes Deployment
- Multi-tenant Support
- AI Risk Engine
- Enterprise Dashboard
#Contributing
Contributions are welcome!
Feel free to fork the repository, create a feature branch, and submit a Pull Request.
Jay Joshi
GitHub: https://github.com/jay0237
LinkedIn: https://www.linkedin.com/in/jay-joshi-12aa04283/
If you found this project useful, consider giving it a ⭐ on GitHub.
It helps the project reach more developers and motivates future development.
This project is licensed under the MIT License.