Skip to main content
v1.0 — Production Ready

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.

config.yaml
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.

config.yaml
# Scoring formula
score = credits × (available_slots + 1) / (queue_depth + 1)

# Highest score wins the request

Per-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.

config.yaml
health:
  circuit_breaker:
    failure_threshold: 3
    reset_timeout: 60s
    window_size: 10

Auto-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.

config.yaml
continuation:
  enabled: true
  max_rounds: 5
  context_threshold: 0.95

Output 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.

config.yaml
sanitize:
  mode: "full"  # identity | xml | full
  strip_xml_tags: true
  strip_builtin_tools: true

Distributed 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.

config.yaml
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.yaml

Multi-Node Cluster

N identical nodes behind nginx. Shared state via Redis Pub/Sub. Production-grade.

make prepare-docker && make up-multi

Docker Compose

Full stack in one command. Gateway + PostgreSQL + Redis + monitoring.

make up-monitoring

Why Drawbridge

Compared to direct API calls and other gateway solutions.

FeatureDrawbridgeDirect APIOther Gateways
OpenAI SDK compatibleVaries
Multi-account poolingLimited
Credit-aware routing
Auto-continuation
Per-account circuit breakerBasic
Distributed clusteringVaries
Session isolationManualVaries
Output sanitization
Zero code changesVaries

Start Using Drawbridge Gateway

Self-hosted, open infrastructure. Deploy in minutes, scale to hundreds of accounts.