grid-safety
GRID Safety layer and Cognitive Privacy Shield: real-time safety enforcement, PII detection, masking, and compliance presets (GDPR, HIPAA, PCI-DSS) for AI inference.
Install
pip install grid-safety
Minimal usage
Cognitive Privacy Shield (library)
from safety.privacy import get_privacy_engine, PrivacyPreset, AsyncPIIDetector
# Get engine with a compliance preset
engine = get_privacy_engine(preset=PrivacyPreset.BALANCED)
# Detect PII
detections = await engine.detect("Contact me at user@example.com")
# Process (detect + mask/block/ask)
result = await engine.process("My SSN is 123-45-6789")
print(result.processed_text) # Masked or blocked per preset
print(result.detections)
Run the Safety API server
safety-api
Runs the FastAPI app (auth, rate limiting, pre-check, Privacy Shield middleware, inference queue). Configure via environment variables:
| Variable | Default | Description |
|---|---|---|
SAFETY_API_HOST |
0.0.0.0 |
Bind host |
SAFETY_API_PORT |
8000 |
Bind port |
SAFETY_API_RELOAD |
(off) | Set to 1, true, or yes to enable reload |
Endpoints include:
POST /infer— Submit inference (enqueued to Redis)POST /privacy/detect— Detect PII in textPOST /privacy/mask— Mask or block PIIPOST /privacy/batch— Batch PII detection/masking (up to 100 texts)GET /health,GET /metrics
Set SAFETY_DEGRADED_MODE=true to run without Redis (e.g. for tests).
Architecture
The Cognitive Privacy Shield is GRID's core safety and privacy API. For pipeline details, integration points, and key files, see:
- Safety Layer & Cognitive Privacy Shield — Architecture (in the GRID repo)
License
MIT. See LICENSE.
Metadata
Release files for grid-safety 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grid_safety-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for grid_safety-1.0.2-py3-none-any.whl |
Release files / grid_safety-1.0.2-py3-none-any.whl
| Download URL | grid_safety-1.0.2-py3-none-any.whl |
|---|---|
| Size | 244.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c3dfd3254167eb3a38609d65c71f19ccb123035747a127a4ba83b2f0b6e0576
|
|
BLAKE2b-256 checksum How to use checksums |
1c38dce1510c24c73cbd33d09b1992706dd041ac948fd5021dbcc5a1ebbdfb56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for grid-safety 1.0.2
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.