Quick Start

Install AnyRouter, add your API keys, and start routing in under a minute.

Install

bash
# macOS / Linux
$ curl -fsSL https://www.anyrouter.planixx.com/scripts/install.sh | bash
powershell
# Windows (PowerShell as Admin)
PS> powershell -c "irm https://www.anyrouter.planixx.com/scripts/install.ps1 | iex"

Run

bash
# Start the interactive TUI
$ anyrouter

# Or start directly in server mode
$ anyrouter --serve

Use

Point your LLM client to:

bash
# AnyRouter endpoint (drop-in for OpenAI SDK)
$ http://127.0.0.1:9876/v1/chat/completions

That's it. AnyRouter works as a drop-in replacement for any OpenAI SDK.

Configuration

Configuration is stored in anyrouter.yaml. You can edit it directly or use the interactive TUI.

Basic Structure

server:
  host: 127.0.0.1
  port: 9876
  log_level: info

providers:
  openai:
    enabled: true
    base_url: https://api.openai.com/v1
    api_key: ${OPENAI_API_KEY}
    format: openai
    models:
      - gpt-4o
      - gpt-4o-mini

Multiple API Keys

openai:
  api_keys:
    - ${OPENAI_KEY_1}
    - ${OPENAI_KEY_2}
    - ${OPENAI_KEY_3}

Setting Up Providers

Set your API keys as environment variables. AnyRouter reads them at startup.

# OpenAI
export OPENAI_API_KEY=sk-...

# Anthropic
export ANTHROPIC_API_KEY=sk-ant-...

# Google Gemini
export GEMINI_API_KEY=...

# Or create a .env file (optional)

AnyRouter supports 30+ providers. The anyrouter.yaml file includes defaults for all of them — just set the corresponding environment variables.

Model Routing

Requests are routed to the correct provider based on the model name. Pre-configured patterns handle all major providers.

# Default routing patterns
models:
  - pattern: claude-    → anthropic
  - pattern: gpt-       → openai
  - pattern: gemini-    → gemini
  - pattern: deepseek-  → deepseek
  - pattern: mistral-   → mistral
  - pattern: grok-      → xai

Add custom routing patterns for any model or provider.

Smart Failover

AnyRouter automatically handles failures at three levels:

Key-Level Failover

If one API key hits a rate limit, the next key is tried automatically.

Model-Level Failover

openai:
  models:
    - gpt-4o
  model_fallbacks:
    - gpt-4o-mini

Provider-Level Failover

openai:
  fallbacks:
    - azure
    - openrouter

The failover chain is: Key 1 → Key 2 → Model fallback → Provider fallback. If all fail, the client receives a clear error.

API Reference

POST /v1/chat/completions

OpenAI-compatible chat completions endpoint. Accepts standard OpenAI request format.

POST /v1/messages

Anthropic-compatible messages endpoint. Accepts standard Anthropic request format.

GET /v1/models

Returns the list of available models across all configured providers.

GET /health

Health check endpoint. Returns provider health status.

GET /debug/routes

Debug endpoint showing current route mappings.

Interactive TUI

The TUI provides a full terminal interface for managing AnyRouter:

  • Start/Stop Server — Toggle the proxy server
  • View Health — Real-time provider health status
  • Edit Config — Modify providers and settings without editing YAML
  • Monitor Requests — Watch live request flow
# Launch the TUI
anyrouter

Building from Source

bash
$ git clone https://github.com/JeanChristopherPL/AnyRouter-Ai.git
$ cd AnyRouter-Ai
$ go build -o anyrouter .

Requires Go 1.21 or later.

Newsletter

Stay Updated

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

No spam. Unsubscribe anytime.