JAiRouter is a production-ready AI model gateway that provides a unified
1.3K
Production-Ready AI Model Gateway
OpenAI-compatible API for unified routing, load balancing & failover
across Ollama, vLLM, GPUStack, Xinference, and more
中文 • Docs • English Docs • Discussions
# 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
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.
| 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 |
┌─────────────────────────────────────────────────────────────────┐
│ Your Application │
│ (OpenAI SDK / LangChain / LlamaIndex) │
└─────────────────────────────────┬───────────────────────────────┘
│
▼ OpenAI-Compatible API
┌─────────────────────────────────────────────────────────────────┐
│ JAiRouter Gateway │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Routing │ │ Balance │ │ Limit │ │ Circuit │ │ Auth │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Observability & Persistence │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────┬───────────────────────────────┘
│
┌──────────────┬───────────┼───────────┬──────────────┐
▼ ▼ ▼ ▼ ▼
┌───────┐ ┌───────┐ ┌───────┐ ┌──────────┐ ┌───────┐
│Ollama │ │ vLLM │ │GPUStack│ │Xinference│ │ OpenAI │
└───────┘ └───────┘ └───────┘ └──────────┘ └───────┘
| 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 |
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)
# 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
}'
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.
One-API focuses on API key management and billing. JAiRouter focuses on local model gateway with advanced resilience patterns and observability.
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 | ✅ | ❌ | ❌ | ✅ |
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
| 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/ |
LTS Release: v2.6.11 is the Long-Term Support version, maintained until 2028-05.
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
JAiRouter is released under the Apache 2.0 License.
Star ⭐ this repo if you find it useful!
Made with ❤️ by the JAiRouter Team
Content type
Image
Digest
sha256:ef9429cc5…
Size
180.5 MB
Last updated
7 days ago
docker pull sodlinken/jairouter