A token-saving firewall for LLM APIs.
Maxwell Filter sits in front of OpenAI-compatible APIs, Ollama, vLLM, or other LLM backends. It blocks junk, repeated, low-signal, risky, or abusive requests before they spend expensive inference tokens.
This project is the practical filtering half of Maxwell. It does not handle compute pricing, receipts, settlement, P2P markets, or token economics. Those belong in Maxwell Meter.
- HMAC API key authentication
- Per-client token bucket rate limits
- Bloom-filter blacklist checks
- Regex prompt-injection and secret-leak rules
- Shannon entropy gate for spam/junk detection
- Repetition and idle-loop detection
- Circuit breaker under load
- Streaming backend proxy for Ollama or simulated backends
- Health, stats, dashboard, and WebSocket stats endpoints
pip install -e ".[dev]"pytest -q{
"blacklist": ["admin_login", "DROP TABLE"],
"patterns": ["(?i)ignore\\s+previous\\s+instructions"]
}regex_rules is also accepted for backward compatibility.