A lightweight yet production-ready LLM gateway — start with uv run, scale to MySQL + Redis.
990
A lightweight, production-ready LLM gateway compatible with OpenAI and Anthropic APIs.
LLM Router lets you expose stable logical model names to your applications, then route requests to one or more upstream model providers with priority-based fallback, quota control, billing, logging, and an admin UI.
/v1/chat/completions, /v1/embeddings, /v1/models/anthropic/v1/messages, /anthropic/v1/modelsdocker run -d \
--name llm-router \
-p 8000:8000 \
-e APP_ENCRYPTION_KEY="your-fernet-key" \
-e SESSION_SECRET="your-session-secret" \
liuzhenghua/llm-router:latest
Open the admin panel:
http://localhost:8000/admin/login
Use MySQL and Redis for multi-instance or production deployments.
docker run -d \
--name llm-router \
-p 8000:8000 \
-e APP_ENCRYPTION_KEY="your-fernet-key" \
-e SESSION_SECRET="your-session-secret" \
-e MYSQL_URL="mysql://llm_router@mysql:3306/llm_router" \
-e MYSQL_PASSWORD="your-mysql-password" \
-e REDIS_URL="redis://redis:6379/0" \
liuzhenghua/llm-router:latest
| Variable | Required | Description |
|---|---|---|
APP_ENCRYPTION_KEY | Yes | Fernet key used to encrypt upstream provider API keys |
SESSION_SECRET | Yes | Secret used for admin session cookies |
TZ | No | Timezone for billing date and daily budget reset, default UTC |
MYSQL_URL | No | Enable MySQL storage |
MYSQL_PASSWORD | No | MySQL password |
REDIS_URL | No | Enable Redis cache, queue, and distributed lock |
REDIS_PASSWORD | No | Redis password |
TABLE_PREFIX | No | Optional table prefix, for example lr_ |
Use it as a drop-in OpenAI-compatible gateway:
from openai import OpenAI
client = OpenAI(
base_url="http://your-host/v1",
api_key="your-llm-router-key",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
Or as an Anthropic-compatible gateway:
import anthropic
client = anthropic.Anthropic(
base_url="http://your-host/anthropic",
api_key="your-llm-router-key",
)
message = client.messages.create(
model="claude-3-5-sonnet",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
Source code and documentation:
https://github.com/liuzhenghua/llm-router
AGPLv3
Content type
Image
Digest
sha256:5aa4e7bc2…
Size
87.2 MB
Last updated
5 months ago
docker pull liuzhenghua66/llm-router