Skip to main content

Grizzly Guard AI: Deterministic LLM Guardrails Engine

License Python Status

Sub-5ms deterministic firewall for LLM safety. Catches prompt injections, detects jailbreaks, masks PII, and guarantees JSON schema conformity—without cloud dependencies or latency penalties.

The Problem

LLM-connected agents face three critical risks:

  1. Prompt Injection Attacks — Attackers hijack prompts to leak system instructions or data
  2. Jailbreaks — Adversarial inputs bypass safety guardrails
  3. Output Failures — Malformed JSON, undetected PII leakage, or schema mismatches crash production systems

Traditional guardrails add 800ms–2,000ms latency (using another LLM to validate). When every millisecond matters, that's unacceptable.

The Solution

Grizzly Guard AI is the "grizzly bar" in your LLM pipeline—a deterministic screening layer that catches attacks in <5ms with zero cloud dependencies.

Your App → Grizzly Guard AI → LLM Provider
          (inject safety)
            <5ms check    

Installation

# Via pip
pip install grizzly-guard-ai

# Via Docker
docker pull ghcr.io/craftedwithintent/grizzly-guard-ai:0.1.2

Quick Start

1. Ingress Guard (Pre-LLM)

Catch injection attacks before they reach your model:

from grizzly_guard_ai import guard_ingress

result = guard_ingress("User prompt here")
if not result.passed:
    print(f"Blocked: {result.violations}")
    return "Sorry, that input looks suspicious."

# Continue with sanitized prompt
response = model.chat(result.masked_payload)

2. Egress Guard (Post-LLM)

Repair JSON, validate schema, mask PII in responses:

from grizzly_guard_ai import guard_egress, SchemaSpec

schema = SchemaSpec(
    json_schema={
        "type": "object",
        "properties": {"answer": {"type": "string"}}
    },
    required_fields=["answer"],
    strict=False
)

result = guard_egress(model_output, schema=schema)
print(f"Safe output: {result.masked_payload}")  # Guaranteed valid JSON

3. Proxy Server (Sidecar)

Run as a reverse proxy between your app and LLM provider:

# Terminal 1: Start Grizzly Guard AI
grizzly-guard-ai proxy --port 8081

# Terminal 2: Your app points to Grizzly Guard AI
export OPENAI_BASE_URL=http://localhost:8081/v1
python app.py

Key Features

Feature What It Does
Prompt Injection Detection Heuristic + entropy scoring (<3ms)
Jailbreak Patterns Blocks known attack signatures (DAN mode, etc.)
PII Masking Redacts SSNs, emails, API keys, phone numbers before upload
JSON Repair Fixes malformed JSON without re-prompting LLM
Schema Validation Enforces Pydantic/JSON schema compliance
Sub-5ms Latency All operations guaranteed <5ms (P99)
Zero Cloud Deps Runs entirely locally
Python Library Direct import or FastAPI server

Performance

Metric Value
Injection detection <3ms (P50)
PII masking <1ms (P50)
JSON repair <1ms (P50)
Full pipeline <5ms (P99)
Latency vs LLM-based 99.7% faster (5ms vs 2,000ms)
Cloud dependencies None

Architecture

Two-Guard Pipeline:

1. INGRESS GUARD (Pre-LLM)
   ├─ Injection classification (heuristics + entropy)
   ├─ PII detection & masking
   ├─ Jailbreak pattern matching
   └─ Token limit validation

2. LLM (Your model)

3. EGRESS GUARD (Post-LLM)
   ├─ JSON repair (no re-prompting)
   ├─ Schema validation
   ├─ PII redaction (accidental leakage)
   └─ Structural guarantee

Stack:

  • Logic: Pure functional validators (injection heuristics, PII patterns, JSON repair)
  • Server: FastAPI proxy with async httpx forwarding
  • Deployment: CLI, Python library, or Docker container

Full Example

Complete production example with Docker Compose:

version: '3.8'
services:
  grizzly:
    image: ghcr.io/craftedwithintent/grizzly-guard-ai:0.1.2
    ports:
      - "8081:8081"
    environment:
      - GRIZZLY_INJECTION_THRESHOLD=0.3
      - GRIZZLY_MASK_INGRESS_PII=true

  app:
    build: .
    ports:
      - "9000:9000"
    environment:
      - OPENAI_BASE_URL=http://grizzly:8081/v1
    depends_on:
      - grizzly

Configuration

Environment Variables

# Risk threshold (0.0–1.0, default 0.3)
GRIZZLY_INJECTION_THRESHOLD=0.3
\n# Mask PII before sending to LLM
GRIZZLY_MASK_INGRESS_PII=true

# Mask PII in LLM responses  
GRIZZLY_MASK_EGRESS_PII=true

# Proxy settings
GRIZZLY_PORT=8081
GRIZZLY_HOST=0.0.0.0

CLI Commands

# Start proxy server
grizzly-guard-ai proxy --port 8081 --host 127.0.0.1

# Scan a prompt
grizzly-guard-ai scan --prompt "User input here"

Testing

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v --cov=src/grizzly_guard_ai

# Expected: 9/9 critical issues resolved ✅
# Coverage: 70%+ enforced

Deployment

Local Development

pip install -e .
grizzly-guard-ai proxy --port 8081

Docker

docker run -p 8081:8081 ghcr.io/craftedwithintent/grizzly-guard-ai:0.1.2

Kubernetes

kubectl apply -f deploy/grizzly-guard-ai.yaml

See Kubernetes manifest in repository.

What's Next?

Phase 2 (Upcoming):

  • Dynamic threat intelligence (automatic signature updates)
  • Streaming egress guard (byte-by-byte token inspection)
  • ONNX semantic classifiers
  • SIEM integration (Datadog, Splunk, OpenTelemetry)

Phase 3 (Enterprise):

  • Custom fine-tuned models
  • Regulatory compliance packs (HIPAA, PCI-DSS, GDPR)
  • Multi-tenant audit logging

Documentation

Support

License

MIT License. See LICENSE.


CraftedWithIntent™ — Deterministic LLM Safety at the Speed of Inference.

Metadata

Release files for grizzly-guard-ai 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grizzly-guard-ai 0.1.2
File Size Uploaded Provenance
grizzly_guard_ai-0.1.2.tar.gz 56.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for grizzly-guard-ai 0.1.2
File Interpreter ABI Platform
grizzly_guard_ai-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 70.6 kB

Release files / grizzly_guard_ai-0.1.2.tar.gz

Download URL grizzly_guard_ai-0.1.2.tar.gz
Size 56.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e01443683fb6779e3fcd7931cf527e3f67b85fa56f707dba877e7c8a30fc594d
BLAKE2b-256 checksum
How to use checksums
f83af084318d3e55e230d32a552644db7c98a146a08c44742eb6bcd7e839e077
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / grizzly_guard_ai-0.1.2-py3-none-any.whl

Download URL grizzly_guard_ai-0.1.2-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
832cc9a39d22ceebc21896ce074e34c959b75789e6dbf753b3d15edbab2efaf7
BLAKE2b-256 checksum
How to use checksums
9fc03fe767918d3c5031f14ce0ff871fd92b27a1ad087c3d0c52514e2830e54d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for grizzly-guard-ai 0.1.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page