Drawbridge Gateway
OpenAI-compatible AI gateway that aggregates multiple accounts into a single endpoint with intelligent routing, automatic failover, and zero client-side changes.
Without Drawbridge
- Single account = single point of failure
- Hit credit limits mid-conversation
- Manual failover when accounts go down
- Truncated responses with no recovery
- Custom client code for each provider
- No visibility into cost distribution
With Drawbridge
- N accounts aggregated behind one endpoint
- Credit-aware routing prevents exhaustion
- Circuit breaker isolates failures automatically
- Auto-continuation recovers truncated outputs
- Standard OpenAI SDK — zero code changes
- Per-account metrics and usage analytics
Features In Depth
Every capability backed by production-verified implementation.
Multi-Account Aggregation
Combine 2, 10, or 100 AI accounts behind a single API endpoint. Each account gets its own process pool with independent health monitoring. Scale beyond single-key limits without changing client code.
accounts:
- id: "pro-1"
pool_size: 3
tier: "pro"
- id: "pro-2"
pool_size: 3
tier: "pro"Credit-Aware Scheduling
Not round-robin. Our scheduler scores each account by: remaining credits, available pool slots, and queue depth. Requests always route to the optimal account, maximizing throughput and minimizing wait time.
# Scoring formula
score = credits × (available_slots + 1) / (queue_depth + 1)
# Highest score wins the requestPer-Account Circuit Breaker
Sliding window failure detection per account. When an account hits the failure threshold, it's automatically isolated — no more requests until recovery. Half-open probes test readiness before restoring traffic.
health:
circuit_breaker:
failure_threshold: 3
reset_timeout: 60s
window_size: 10Auto-Continuation
AI responses get truncated. Our 3-layer heuristic detects this (context usage > 95%, output > 4000 chars, non-natural ending) and automatically continues on the same session. Up to 5 rounds per request.
continuation:
enabled: true
max_rounds: 5
context_threshold: 0.95Output Sanitization
Clean responses, every time. Strips internal XML artifacts, built-in tool markers, and identity metadata. Configurable pipeline: identity mode (passthrough), XML stripping, or full sanitization.
sanitize:
mode: "full" # identity | xml | full
strip_xml_tags: true
strip_builtin_tools: trueDistributed Clustering
Horizontal scaling with zero coordination overhead. Nodes register via heartbeat (3s interval, 10s TTL), coordinate through Redis Pub/Sub, and forward requests cross-node when the optimal account is remote.
node:
id: "node-1"
address: "drawbridge-1:8080"
redis:
url: "redis://valkey:6379"Deployment Options
From development laptop to production cluster.
Single Node
One binary, all accounts. PostgreSQL + optional Redis. Perfect for dev and staging.
make build && ./bin/drawbridge --config config.yamlMulti-Node Cluster
N identical nodes behind nginx. Shared state via Redis Pub/Sub. Production-grade.
make prepare-docker && make up-multiDocker Compose
Full stack in one command. Gateway + PostgreSQL + Redis + monitoring.
make up-monitoringWhy Drawbridge
Compared to direct API calls and other gateway solutions.
| Feature | Drawbridge | Direct API | Other Gateways |
|---|---|---|---|
| OpenAI SDK compatible | Varies | ||
| Multi-account pooling | Limited | ||
| Credit-aware routing | |||
| Auto-continuation | |||
| Per-account circuit breaker | Basic | ||
| Distributed clustering | Varies | ||
| Session isolation | Manual | Varies | |
| Output sanitization | |||
| Zero code changes | Varies |
Start Using Drawbridge Gateway
Self-hosted, open infrastructure. Deploy in minutes, scale to hundreds of accounts.