About this project

subrelay is a lightweight relay gateway designed to manage multiple OpenAI and Anthropic API credentials. It acts as a middle layer between users and upstream providers, offering features like weighted-random selection, automatic failover, and rate-limit backoff. Unlike heavier alternatives, it uses SQLite for storage and requires no external dependencies like Redis or PostgreSQL. Key capabilities include: - Protocol Compatibility: Supports both OpenAI Chat Completions and Anthropic Messages APIs, with byte-level passthrough when protocols match to preserve tool-calling and provider-specific fields. - Credential Management: Handles multiple keys with daily budget enforcement, concurrency limits, and automatic cooldowns on 429 or 5xx errors. - New API Integration: Features a sync-newapi command to reconcile local configurations with New API channels, supporting dry runs, pruning, and GitOps workflows. - Observability: Provides Prometheus metrics, health checks, and a doctor CLI tool for probing credential health. - Developer Friendly: Simple YAML configuration with environment variable interpolation and a single-process deployment model via Python or Docker.