Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,380 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JAiRouter

JAiRouter - AI Model Gateway

Production-Ready AI Model Gateway

OpenAI-compatible API for unified routing, load balancing & failover
across Ollama, vLLM, GPUStack, Xinference, Claude, Gemini, and more

GitHub stars Docker Pulls License Release

中文DocsEnglish DocsDiscussions


Quick Start

# Start with Docker (no configuration needed)
docker run -d --name jairouter -p 8080:8080 sodlinken/jairouter:latest

# Open Web Console: http://localhost:8080/admin
# Default: admin / ChangeMeOnFirstStartup123456

What is JAiRouter?

JAiRouter is a production-ready AI model gateway that provides a unified, OpenAI-compatible API for managing multiple LLM backends. It handles load balancing, rate limiting, circuit breaking, and failover — so you can focus on building applications, not managing infrastructure.

Key Benefits

Problem JAiRouter Solution
Multiple model endpoints to manage Single unified API endpoint
Manual failover when services fail Automatic circuit breaker
Implementing auth for each service JWT + API Key built-in
Scattered logs and metrics Centralized observability
Service restart for config changes Hot reload via Web Console

Core Features

  • 🔌 OpenAI-Compatible API — Drop-in replacement for OpenAI SDK, LangChain, LlamaIndex
  • 🔧 Configurable Adapters — Add new AI providers (DeepSeek, Zhipu, etc.) via config or Web UI, no code needed
  • ⚖️ Smart Load Balancing — Round-robin, weighted, least-connections, IP-hash, consistent-hash
  • 🛡️ Rate Limiting — Token bucket, leaky bucket, sliding window algorithms
  • 🔥 Circuit Breaker — Auto failover with configurable thresholds and recovery
  • 🔐 Authentication — JWT + API Key dual authentication with audit logging
  • 📊 Observability — Prometheus metrics, OpenTelemetry tracing, real-time dashboards
  • 💾 Persistence — Redis / H2 / File storage for distributed deployment
  • 🎛️ Web Console — Visual management, version control, configuration rollback

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         Your Application                         │
│                 (OpenAI SDK / LangChain / LlamaIndex)           │
└─────────────────────────────────┬───────────────────────────────┘
                                  │
                                  ▼ OpenAI-Compatible API
┌─────────────────────────────────────────────────────────────────┐
│                         JAiRouter Gateway                        │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐   │
│  │ Routing │ │ Balance │ │  Limit  │ │ Circuit │ │   Auth  │   │
│  └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘   │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │              Observability & Persistence                 │   │
│  └─────────────────────────────────────────────────────────┘   │
└─────────────────────────────────┬───────────────────────────────┘
                                  │
       ┌──────────────┬───────────┼───────────┬──────────────┐
       ▼              ▼           ▼           ▼              ▼
   ┌───────┐     ┌───────┐   ┌───────┐   ┌──────────┐   ┌───────┐
   │Ollama │     │ vLLM  │   │GPUStack│  │Xinference│   │ OpenAI │
   └───────┘     └───────┘   └───────┘   └──────────┘   └───────┘

Supported AI Backends

Built-in Adapters

Backend Chat Embedding Rerank TTS STT Image Notes
Ollama - - - - Local inference
vLLM - - - - High-throughput
GPUStack Full-featured
Xinference Multi-model
LocalAI - OpenAI-compatible
OpenAI - Cloud fallback
Anthropic Claude - - - - - Native Claude API
Google Gemini - - - - - Native Gemini API

Configurable Adapters (No Code Required)

Add any OpenAI-compatible provider via configuration or Web UI:

Provider Configuration
DeepSeek adapter-definitions: deepseek: type: openai-compatible
Zhipu (GLM) adapter-definitions: zhipu: type: openai-compatible
Moonshot adapter-definitions: moonshot: type: openai-compatible
Qwen (Tongyi) adapter-definitions: qwen: type: openai-compatible
Baichuan adapter-definitions: baichuan: type: openai-compatible
Minimax adapter-definitions: minimax: type: openai-compatible

📖 See Adapter Configuration Guide for details.


Usage Example

Python with OpenAI SDK

from openai import OpenAI

# Point to JAiRouter instead of OpenAI
client = OpenAI(
    base_url="http://localhost:8080/v1",
    api_key="not-needed"  # JAiRouter handles authentication
)

# Use any model from your configured backends
response = client.chat.completions.create(
    model="llama3.2",  # Routed to Ollama, vLLM, or GPUStack
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

Add a Model Backend

# Via API - Add Ollama instance
curl -X POST http://localhost:8080/api/config/instance/add/chat \
  -H "Content-Type: application/json" \
  -H "Jairouter_token: your-jwt-token" \
  -d '{
    "name": "llama3.2",
    "baseUrl": "http://localhost:11434",
    "path": "/v1/chat/completions",
    "weight": 1
  }'

Why Choose JAiRouter?

vs Nginx

Nginx is a general-purpose web server. JAiRouter is purpose-built for AI/LLM workloads with OpenAI-compatible routing, circuit breaking, and model-aware load balancing.

vs One-API

One-API focuses on API key management and billing. JAiRouter focuses on local model gateway with advanced resilience patterns and observability.

vs LangChain

LangChain is an application framework. JAiRouter is an infrastructure layer that works beneath LangChain to provide routing, failover, and monitoring.

Feature JAiRouter Nginx One-API LangChain
OpenAI Compatible
Load Balancing
Circuit Breaker
Rate Limiting
Web Console
Config Hot Reload
Version Control
OpenTelemetry

Benchmarks

Performance overhead compared to direct backend access:

Scenario Direct Ollama Via JAiRouter Overhead
Single request 1.2s 1.21s <1%
100 concurrent 45s 48s ~6%
With rate limiting N/A Configurable -
With circuit breaker N/A Auto failover -

Benchmarks: Ubuntu 22.04, 16 cores, 32GB RAM, Ollama 0.1.27


Documentation

Resource Link
📖 Full Documentation https://jairouter.com
📘 API Reference http://localhost:8080/swagger-ui
🚀 Deployment Guide https://jairouter.com/en/deployment/
🔧 Configuration https://jairouter.com/en/configuration/
📊 Monitoring https://jairouter.com/en/monitoring/

Roadmap

  • Core gateway functionality
  • Multiple backend adapters (Ollama, vLLM, GPUStack, Xinference, LocalAI)
  • Load balancing with multiple strategies
  • Rate limiting algorithms
  • Circuit breaker with auto recovery
  • Web management console
  • JWT + API Key authentication
  • OpenTelemetry distributed tracing
  • Configuration version control
  • Docker image optimization (Alpine/Distroless)
  • API Key quota management
  • Call history persistence
  • RBAC role-based access control
  • Anthropic Claude adapter
  • Google Gemini adapter

Current Release: v2.8.3 | LTS Release: v2.6.11 (maintained until 2028-05)


Contributing

We welcome contributions! See Contributing Guide.

git clone https://github.com/Lincoln-cn/JAiRouter.git
cd JAiRouter/modelrouter
mvn clean package -DskipTests
java -jar target/modelrouter.jar

Support


License

JAiRouter is released under the Apache 2.0 License.


Star ⭐ this repo if you find it useful!

Made with ❤️ by the JAiRouter Team

About

JAiRouter is a production-ready AI model gateway that provides a unified, OpenAI-compatible API for managing multiple LLM backends. It handles load balancing, rate limiting, circuit breaking, and failover — so you can focus on building applications, not managing infrastructure.

Topics

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages