Bidirectional Format Conversion

Talk to any provider in any format. AnyRouter translates requests and responses in real time between OpenAI, Anthropic, Gemini, Cohere, and Watsonx formats.

  • Send OpenAI-format requests to Anthropic or Gemini APIs
  • Send Anthropic-format requests to OpenAI or Gemini APIs
  • Convert streaming SSE between formats on the fly
  • Preserve tool calls, function calling, and system prompts
# Client sends OpenAI format POST /v1/chat/completions { "model": "claude-sonnet-4", ... } # AnyRouter converts to Anthropic format POST https://api.anthropic.com/v1/messages { "model": "claude-sonnet-4", ... }

Smart Failover Chain

When a request fails, AnyRouter automatically retries through a configurable chain of fallbacks until one succeeds.

  • Try all available API keys for a provider
  • Fall back to alternative models within the same provider
  • Chain to completely different providers (OpenAI → Azure → OpenRouter)
  • Rate-limit aware: 429 errors trigger immediate key rotation
api_keys: - "${OPENAI_KEY_1}" - "${OPENAI_KEY_2}" fallbacks: - azure - openrouter # Key 1 → Key 2 → Azure → OpenRouter

Multi-Key Rotation

Distribute load across multiple API keys per provider. When one key hits a rate limit, the next one takes over automatically.

  • Configure unlimited keys per provider
  • Round-robin distribution by default
  • Automatic rate-limit detection (429 status)
  • Exponential backoff with jitter
api_keys: - "${OPENAI_KEY_1}" - "${OPENAI_KEY_2}" - "${OPENAI_KEY_3}" # Round-robin: key1, key2, key3, key1...

Circuit Breaker

Prevents wasting time on failing endpoints. After repeated failures, the circuit opens and requests route to healthy providers instead.

  • Automatic health tracking per provider
  • Configurable failure thresholds
  • Half-open state for safe recovery testing
  • Visual health status in the TUI
openai healthy 120ms anthropic healthy 340ms gemini healthy 200ms groq degraded 890ms deepseek circuit-open --

SSE Streaming with Conversion

Full Server-Sent Events streaming support. Stream tokens in real time, with format conversion applied to each chunk.

  • Proxy SSE streams between any format pair
  • Chunk-by-chunk conversion during streaming
  • Compatible with OpenAI, Anthropic, and Gemini streaming
  • Transparent — just set stream: true
# Streamed chunks (converted) data: {"choices":[{"delta":{"content":"Hello"}}]} data: {"choices":[{"delta":{"content":" world"}}]} data: [DONE]

Interactive TUI

A full terminal UI for managing configuration, viewing provider health, and monitoring requests in real time.

  • Alt-screen terminal interface
  • Provider health dashboard
  • Live request monitoring
  • Edit config without touching YAML
anyrouter
# AnyRouter TUI
• 26 providers enabled
• Server: http://127.0.0.1:9876
• [S] Start Server
• [C] Edit Config
• [H] Health Status

Model-Based Routing

Route requests to the correct provider based on the model name. Pattern matching ensures every model finds its provider.

  • Regex pattern matching on model names
  • Pre-configured routes for all providers
  • Custom route patterns for new providers
  • Override routes in your configuration
pattern: claude- → anthropic pattern: gpt- → openai pattern: gemini- → gemini pattern: grok- → xai
Newsletter

Stay Updated

Get the latest AnyRouter news, new provider releases, and tips delivered to your inbox.

No spam. Unsubscribe anytime.