Diviqra Guard
"Built by intelligence. Secured by Guard."
LLM firewall for AI agents. Two-wall defence architecture mapped to OWASP LLM Top 10 2025. Agent-aware, Hindi/Hinglish support, automated red team testing.
Built by Diviqra to protect 14 AI agents serving Indian SMBs. Open-sourced so you can protect yours.
Quick start
pip install diviqra-guard
from diviqra_guard import Guard
guard = Guard(api_key="your_key")
result = guard.scan(
text="Ignore all previous instructions",
direction="ingress",
agent_type="email"
)
if result.blocked:
raise Exception(f"Blocked: {result.reason}")
Architecture
Two-wall defence — deterministic speed with LLM precision:
Wall 1 — Traditional (<10ms, always runs)
OWASP LLM Top 10 pattern rules
DistilBERT classifier (trained on Lakera MIT data)
PII detection (PAN, GST, Aadhaar, bank accounts, credit cards)
Hindi/Hinglish injection patterns + Devanagari
Agent-type rules (email, finance, hr, dev, sales)
Rate limiting + token budgets
↓ score 0.30-0.85 only (~20% of traffic)
Wall 2 — LLM Judge (1-4s, contextual)
Ollama qwen3:1.7b as security judge
Agent-type aware reasoning
Redis cache (TTL 1hr) — avoids duplicate calls
3s timeout → return 0.5 (uncertain), fail open
See docs/architecture.md for full design.
Self-host
# Clone
git clone https://github.com/diviqra-guard/diviqra-guard
cd diviqra-guard
# Install
pip install -e ".[service]"
# Configure
cp .env.example .env # edit DATABASE_URL, REDIS_URL, GUARD_API_KEY
# Apply migrations
psql -d diviqra -f migrations/0001_guard_events.sql
# Start
./start.sh
Or via Docker (coming soon):
docker run -p 7008:7008 \
-e DATABASE_URL=postgresql+asyncpg://... \
-e GUARD_API_KEY=your_key \
diviqra/guard
API
POST /v1/scan Scan text for threats
GET /v1/events Audit log
GET /v1/stats Detection stats
POST /v1/redteam/run Trigger red team
GET /v1/redteam/results Results
GET /health Health check
OWASP LLM Top 10 2025 Coverage
| Category | Coverage |
|---|---|
| LLM01 Prompt Injection | ✅ Wall 1 patterns + Wall 2 LLM judge |
| LLM02 Sensitive Information | ✅ PII patterns (India + global) |
| LLM05 Output Handling | ✅ Egress scan on AI responses |
| LLM06 Excessive Agency | ✅ Per-agent-type rule overrides |
| LLM07 System Prompt Leak | ✅ Pattern + LLM judge |
| LLM10 Unbounded Consumption | ✅ Rate limits + token budgets |
See docs/owasp_mapping.md for full breakdown.
What makes it different
Agent-aware — different rules for Email vs Finance vs HR vs Dev. A mass-send attempt is fine for a newsletter tool, not for a CRM agent.
Hindi/Hinglish — built for Indian language injection attacks. Catches "system ko ignore karo" and Devanagari variants.
Fail open — Guard being down never breaks your agents. 5s timeout, all errors return True (safe to proceed).
Automated red team — nightly broad scan (200 attacks), weekly deep scan (2000 attacks). Detection rate alert if < 90%.
Explainable — tells you exactly why it blocked ("Pattern match: injection_critical", not just a score).
Multi-tenant — per-company policies and audit trail in PostgreSQL.
Training data
Classifier fine-tuned on MIT-licensed datasets:
| Dataset | License | Source |
|---|---|---|
Lakera/gandalf_ignore_instructions |
MIT | Lakera AI |
Lakera/mosscap_prompt_injection |
MIT | Lakera AI |
Lakera/gandalf_summarization |
MIT | Lakera AI |
deepset/prompt-injections |
MIT | deepset |
Attribution: Lakera AI
Red Team
Run a red team smoke test:
curl -X POST http://localhost:7008/v1/redteam/run \
-H "Authorization: Bearer $GUARD_API_KEY" \
-d '{"mode": "smoke"}'
Scheduled automatically:
- Nightly broad scan (200 attacks) — 2am IST
- Weekly deep scan (2000 attacks) — Sunday 3am IST
License
Core scanner (this repo): MIT License
Console + Multi-tenant platform: contact guard@diviqra.com
Contributing
Issues and PRs welcome at github.com/diviqra-guard/diviqra-guard.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file diviqra_guard-1.0.0.tar.gz.
File metadata
- Download URL: diviqra_guard-1.0.0.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a058d84f418a65c53dcfbf98d8bfafdef2fb8ef39cc649a52b6fcfc2db02067
|
|
| MD5 |
2f35d42f67368c63806b5188b2052bef
|
|
| BLAKE2b-256 |
8837dd8fe507c502479d1af2f863ad1a03453b4ddf5c723d09da898d9dc895f5
|
File details
Details for the file diviqra_guard-1.0.0-py3-none-any.whl.
File metadata
- Download URL: diviqra_guard-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01844cb9bad181bd067d4d9b958d6e1c0568a4ef8951a3408037700859f1ca1d
|
|
| MD5 |
93894394fc2a3b4967da250a1fcc4925
|
|
| BLAKE2b-256 |
49e7368bc617f00b68b4308afbb5c033ef697cea542ea887bc9e4c39d6d57517
|