Repository navigation
v0.0.3
Gateway
A complete local HTTP proxy for AI API failover.
- Multi-key rotation — configure multiple API keys per endpoint, rotated
round-robin with automatic advance on error - Hybrid backend selection — managed keys tried first, then the caller's
own API key (passthrough), then fallback providers - Fallback chains — route to secondary providers (e.g. OpenRouter) when
the primary is down - Model-level fallback — configure degradation chains per model
(e.g. opus → sonnet → haiku); response includes
x-gateway-model-fallbackheader - Protocol translation — automatic Anthropic ↔ OpenAI format conversion
for cross-provider fallback, including streaming SSE events - Health tracking — per-backend and per-model health with sliding 60-second
error window and status-code-specific cooldowns (429→30s, 500→15s, 502/503→10s) - Pre-flight status check — queries
aistatus.ccat startup to pre-mark
globally degraded models - Configuration modes — maintain multiple YAML configs (production/dev)
and switch at runtime viaPOST /modeor per-request via/m/{mode}/... - Gateway authentication — protect the proxy with separate API keys,
constant-time comparison viahmac.compare_digest - Usage tracking — per-provider/model cost breakdown via
/usageendpoint
with period (today|week|month|all) andgroup_byfilters - Management endpoints —
/health,/status,/usage,/mode - CLI —
python -m aistatus.gateway start [--auto|--config PATH]and
python -m aistatus.gateway initto generate example config - Graceful shutdown on SIGTERM/SIGINT with PID file and log file support
Router
Major feature sync bringing parity with the TypeScript SDK.
- Slug alias system — register multiple slugs for the same provider
(e.g.my-openaialiased toopenai) ProviderNotConfiguredexception — raised when the required API key or
explicit provider config is missing (separate fromProviderNotInstalled)preferparameter —route(prefer=["anthropic", "google"])to bias
fallback ordering toward preferred providerssystemparameter —route("Hello", system="Be concise.")for
convenient system prompt without manual message wrapping- String message shortcut — pass a plain string to
route()instead of
a full messages list - Enhanced cost calculation — cache token tracking (creation + read) in
RouteResponse, correct cost calc that accounts for cached tokens
Provider Adapters
- All adapters (Anthropic, OpenAI, Google, OpenRouter, compatible) —
expanded to support streaming, structured output, multimodal content,
system prompts, and tool use - OpenRouter adapter — rewritten with proper model prefix handling and
fallback model mapping
New Modules
aistatus.content— content block utilitiesaistatus.middleware— hook definitions for request/response interceptionaistatus.stream— streaming response utilities
API Client
StatusAPI— expanded with model search, trending, benchmarks, market
pricing, and recommendation endpoints- Pricing lookup — handles versioned Claude model IDs correctly
Fixes
health.py— replace unboundeddefaultdictwith bounded dict +setdefaulttranslate.py— emit terminal SSE events on stream truncationauth.py— usehmac.compare_digestfor constant-time key comparisonrouter.py—_build_responseno longer ignores cache tokens in cost calcserver.py— fixset.updatestring splitting bug + streaming release leakserver.py— fix gateway response charset handling