Skip to main content

Built for Speed

Raptor is written in Rust using the Axum web framework and Tokio async runtime. Every component is optimized for minimal latency.

Request Flow

Latency Breakdown

Why This Matters

A typical GPT-4 request takes 500-2000ms. Adding 50-100ms of proxy overhead (common with Python/Node) is noticeable. Adding 5ms is not.

Three-Tier Caching

Semantic Cache vs Exact Match

Traditional caches require exact matches. Raptor uses semantic hashing:
We compute a vector embedding, quantize the first 64 dimensions, and hash the result. Semantically similar queries produce the same hash.

Firewall Architecture

The firewall runs before forwarding to upstream:
  1. Extract text from request body (messages, prompt, etc.)
  2. Compute embedding using local ONNX model (~1ms)
  3. Compare against threat patterns via cosine similarity
  4. Block/warn/log based on configured thresholds
For streaming responses, we also monitor the output and can terminate mid-stream if the AI starts generating policy-violating content.

Evidence Pipeline

All requests are logged asynchronously:
Evidence is never on the critical path. Your requests don’t wait for logging.

Tech Stack

Resilience

  • Rate limiting: Per API key, configurable
  • Circuit breakers: Automatic failover on upstream errors
  • Connection pooling: Efficient database/Redis connections
  • Graceful shutdown: In-flight requests complete
Raptor is designed to be invisible. If we add latency you notice, that’s a bug.