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.
Metadata
Release files for agent-safety-middleware 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| agent_safety_middleware-0.1.0.tar.gz | 11.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agent_safety_middleware-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.2 kB
Release files / agent_safety_middleware-0.1.0.tar.gz
| Download URL | agent_safety_middleware-0.1.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ae2a97c8e9c828d2f30a5e3d874f8b80b1e34ff958d039eaa9fccce5055c3f2
|
|
BLAKE2b-256 checksum How to use checksums |
78f32a7027cbbf5d66336240ad0f52a6494c0425c6adffe319bf4762e7511ed4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.2
|
Release files / agent_safety_middleware-0.1.0-py3-none-any.whl
| Download URL | agent_safety_middleware-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b66feae814a7088da13cc77c7874318211033464ddc191c5d0d577d44ceedefb
|
|
BLAKE2b-256 checksum How to use checksums |
a9f1631f62df4a46b9fe176f383a6fdff7d7da1e0c8290bdb19d1bea0a27c485
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.2
|
Security for agent-safety-middleware 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.