Janus is an ultra-low latency reverse proxy designed to secure Large Language Model (LLM) workflows. It acts as a specialized security perimeter positioned between client applications and AI inference providers (such as Ollama, OpenAI, or Anthropic).
Janus provides real-time Prompt Injection Defense and streaming Personally Identifiable Information (PII) redaction while optimizing for minimal throughput overhead.
Project Status (Active Development): The Go-based Proxy Foundation (config loading, routing, body interception) is fully implemented. The gRPC IPC bridge and Python Security Engine (SLM pipeline) are currently under active development.
The following diagram illustrates the hybrid architecture of Janus, distinguishing between the high-concurrency data path and the semantic analysis engine.
graph LR
classDef boundary fill:#f9f,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
classDef primary fill:#e1f5fe,stroke:#0277bd,stroke-width:2px;
classDef secondary fill:#fff3e0,stroke:#ef6c00,stroke-width:2px;
Client(Application Client)
subgraph JanusGateway["Janus Gateway Boundary"]
direction TB
Proxy[Go Proxy Plane <br/> Networking, Buffering, Routing]:::primary
Engine[Python Security Engine <br/> SLM-based Inspection, Semantic Analysis]:::secondary
Proxy <-->|High-Speed IPC / gRPC <br/> Protocol Buffers| Engine
end
Provider(AI Provider <br/> Ollama / Cloud API)
%% Request Flow
Client -->|1. Request <br/> Unsecured Prompt| Proxy
Proxy -->|2. Secure Request <br/> Redacted Prompt| Provider
%% Response Flow
Provider -->|3. Response <br/> Stream| Proxy
Proxy -->|4. Secure Response <br/> Redacted Stream| Client
%% Highlighting components
linkStyle 0,1,2,3 stroke-width:2px,fill:none,stroke:black;
The Proxy Plane is the high-performance edge layer responsible for handling all inbound and outbound traffic.
- TCP connection management
- SSL termination
- HTTP parsing and routing
- Request/response buffering
- Client-side streaming
Go is selected due to its:
- Lightweight concurrency model (goroutines)
- Efficient networking stack (
net/http) - Predictable memory management
- Zero-copy data pathing is used wherever possible to minimize overhead.
- Deterministic PII redaction (e.g., regex for emails, API keys) is handled inline to avoid cross-process calls.
- Streaming-aware processing ensures responses are redacted in real-time without buffering entire payloads.
As responses stream back from the AI provider:
- Data is processed in chunks.
- Redaction rules are applied per chunk.
- Cleaned data is forwarded immediately.
This maintains a near-constant latency floor, critical for real-time applications.
The Intelligence Plane is responsible for semantic security enforcement using machine learning.
- Detecting adversarial prompt injections (jailbreak attempts)
- Identifying sensitive entities requiring context (e.g., PERSON, ORG)
- Performing context-aware redaction
Python is used to leverage:
- Mature ML/NLP ecosystem
- Rapid experimentation and model iteration
- Integration with lightweight models
- Runs as a separate process/container to avoid Go bottlenecks
- Avoids Python’s GIL impacting networking throughput
- Uses Small Language Models (SLMs) instead of full LLMs
This ensures the intelligence layer does not become a system bottleneck.
The Inspection Loop is the synchronization mechanism between the two planes.
- A request arrives at the Proxy Plane.
- If semantic inspection is required:
- The request is paused.
- Payload is serialized.
- Data is sent to the Intelligence Plane via IPC.
- The Python engine returns:
- Safety score
- Redacted content
- The Proxy Plane updates the request.
- Forwarding resumes to the AI provider.
- Protocol: gRPC or optimized HTTP/2
- Transport: Unix sockets / localhost
- Serialization: Protocol Buffers (protobuf)
- Lower latency vs JSON
- Reduced payload size
- Faster parsing on both ends
- Every prompt is treated as potentially malicious
- Detects:
- Prompt injections
- Jailbreak attempts
- Indirect adversarial inputs
-
Real-time masking of:
- Emails
- Credit card numbers
- Phone numbers
- Named entities (e.g., PERSON)
-
Works on:
- Incoming prompts
- Outgoing AI responses
- Achieved via:
- Inline processing (Go)
- Lightweight models (Python)
- Efficient IPC
Janus acts as a drop-in reverse proxy for any OpenAI-compatible API:
- Cloud providers
- Self-hosted models
- Local runtimes (e.g., Ollama)
- Go 1.21+
- Python 3.10+
- Access to an AI provider (API key or local deployment)
# Clone the repository
git clone https://github.com/yourusername/janus.git
cd janus
# Build the Go Proxy
go mod download
go build -o janus-proxy cmd/main.go
# Setup the Python Intelligence Engine
pip install -r requirements.txtserver:
port: 8080
target_url: "http://localhost:11434"
security:
redaction_level: "strict" # options: lax, balanced, strict
injection_shield: true
pii_categories:
- EMAIL
- CREDIT_CARD
- PHONE_NUMBER
- PERSON