Skip to content

LuciferForge/agent-safety-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agent-safety-middleware

One-line safety middleware for AI agent APIs. Prompt injection scanning, cost budgets, decision audit trails.

Install

pip install agent-safety-middleware

FastAPI

from fastapi import FastAPI
from agent_safety_middleware import AgentSafetyMiddleware

app = FastAPI()
app.add_middleware(AgentSafetyMiddleware)

Flask

from flask import Flask
from agent_safety_middleware import FlaskAgentSafety

app = Flask(__name__)
FlaskAgentSafety(app)

Decorator

from agent_safety_middleware import safe_endpoint

@app.post("/chat")
@safe_endpoint(injection_threshold=5, max_cost_per_request=0.50)
async def chat(prompt: str):
    ...

Standalone

from agent_safety_middleware import SafetyGuard

guard = SafetyGuard(injection_threshold=5, max_cost_per_session=10.00)
result = guard.check("user input here")
if not result.safe:
    print(f"Blocked: {result.blocked_reason}")

Automatically scans POST/PUT/PATCH request bodies for injection attacks across 69 patterns. Adds X-Safety-* response headers. Zero config required.

About

One-line safety middleware for AI agent APIs. Prompt injection scanning, cost budgets, decision audit trails. FastAPI + Flask.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages