The restart cycle
Swap a model → edit .env or config → restart the server → lose your debugging state.
Set active-model once. Click any model in the dashboard or pin per app. The next request routes immediately.
SLIR · Switch LLM In Runtime·Self-Hosted AI Gateway
Stop editing config files and restarting servers to test another LLM. Point your app once at http://localhost:4101 with model: "active-model", hot-swap between Ollama, LM Studio, vLLM, OpenAI, Anthropic, and Groq in one click, and trace every millisecond, token, and automatic failover.
$ docker run -d --name slir -p 4100:4101 -p 4101:4101 \ --add-host=host.docker.internal:host-gateway \ -v slir_data:/app/data varad177/slir-app:latest # dashboard UI → http://localhost:4100 # AI gateway → http://localhost:4101/v1 (or /v1/messages)
Indexed 612 prompt tokens locally at $0 cost.
Requests sent with this application key are routed by the rule below.
| TIME | APPLICATION | MODEL | STATUS | LATENCY BREAKDOWN | TOKENS |
|---|---|---|---|---|---|
| 16:56:41 | Your App | gpt-4o-miniFailover from claude-sonnet-4 · Rate limit · | 200 | 980 ms L:0.00s PE:0.18s G:0.80s | 412 |
| 16:54:12 | Your App | nomic-embed-text:latest | 200 | 320 ms L:0.00s PE:0.04s G:0.28s | 612 |
| 16:50:08 | support-bot | google/gemma-4-31b-it | 200 | 1.14s L:0.00s PE:0.20s G:0.94s | 940 |
01 — Why SLIR
Four everyday bottlenecks when building AI apps locally or on-prem. SLIR removes all four without changing how your code calls OpenAI or Anthropic SDKs.
Swap a model → edit .env or config → restart the server → lose your debugging state.
Set active-model once. Click any model in the dashboard or pin per app. The next request routes immediately.
A local call took 3 seconds. Was it VRAM loading, a huge prompt context, or slow generation?
X-ray every request. Inspect Load (L), Prompt Eval / TTFT (PE), and Generation speed (G) on every log row.
Multiple bots and scripts hit different keys with zero per-app token or dollar tracking.
Attribute & enforce budgets. Issue mp_live_ app keys with pricing rules, daily/monthly caps, webhooks, and 429 hard blocks.
One upstream 429 rate limit or crashed container breaks your agent workflow silently.
Fail over with full traces. Per-app fallback chains retry on 429, 5xx, timeout or network error and log every attempt message.
02 — Capabilities
Everything developers end up duct-taping together around local and cloud LLMs—packaged into a single zero-config container.
Send model: "active-model" globally or pin specific models per app. Swap between local Ollama and cloud APIs in 1 click without restarts.
model: "active-model"
Separates cold VRAM weight load, prompt evaluation (TTFT), and generation throughput (tok/s), plus live temperature and num_ctx tuning.
L · PE · G · tok/s
Exposes POST /v1/chat/completions and native POST /v1/messages with full bidirectional streaming SSE, tool calling, vision, and json_schema.
/v1/chat/completions · /v1/messages
Ordered chains of up to 5 fallback models recover from 429, 5xx, timeouts, and network errors, logging every attempt HTTP code and error.
step-by-step error log
Versioned pricing rules plus custom-model per-1M rates, daily/monthly hard 429 caps, spend projection, and Slack or Discord webhooks.
block at 100% · webhooks
Filter by app, model, status, stream, or routing outcome (Failover only/succeeded/failed), inspect cURL/JSON, and export CSV.
X-SLIR-Telemetry header
Test system and user prompts with live SSE token streaming, attribute runs to an app key, and benchmark models side by side.
live SSE · side-by-side
Embedded SQLite in WAL mode stays on your machine. Prompts and completions are never saved—only anonymous telemetry and cost metadata.
0 prompts stored · /api/metrics
04 — Latency X-ray
Most tools tell you a request took three seconds. SLIR breaks it into the three phases that actually explain why.
VRAM weight and KV cache initialization. The badge tells you cold load versus resident warm.
Time to first token. The real cost of a large context window, measured before generation starts.
Token generation speed in tokens per second, taken from the provider’s own counters.
Real timings come from Ollama’s own counters on your hardware. The panel on the right is an interactive estimate.
Eval time 2.36s · 160 tokens out
03 — Integration
Point any SDK at port 4101 with an application key (mp_live_...) from the dashboard. SLIR handles streaming, tool calls, schema translation, failover, and budget enforcement.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:4101/v1",
api_key="mp_live_your_application_key", # records telemetry, failover & budgets
)
response = client.chat.completions.create(
model="active-model", # hot-swappable from the SLIR dashboard
messages=[{"role": "user", "content": "Hello SLIR!"}],
)
print(response.choices[0].message.content)from anthropic import Anthropic
client = Anthropic(
base_url="http://localhost:4101",
api_key="mp_live_your_application_key", # sent as x-api-key
)
message = client.messages.create(
model="active-model", # routes to Anthropic OR any local/OpenAI model
max_tokens=256,
messages=[{"role": "user", "content": "Summarize latency telemetry."}],
)
print(message.content[0].text)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "http://localhost:4101/v1",
apiKey: "mp_live_your_application_key",
});
const response = await client.chat.completions.create({
model: "active-model",
messages: [{ role: "user", content: "Status check." }],
});
console.log(response.choices[0].message.content);using System.Net.Http.Headers;
using System.Net.Http.Json;
var client = new HttpClient { BaseAddress = new Uri("http://localhost:4101/v1/") };
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "mp_live_your_application_key");
var body = new {
model = "active-model", // resolved by SLIR at runtime
messages = new[] {
new { role = "user", content = "Analyze this telemetry anomaly." }
}
};
var response = await client.PostAsJsonAsync("chat/completions", body);
Console.WriteLine(await response.Content.ReadAsStringAsync());curl http://localhost:4101/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer mp_live_your_application_key" \
-d '{
"model": "active-model",
"messages": [
{ "role": "user", "content": "Summarize this log in one line." }
]
}'Checks X-SLIR-Telemetry: recorded · Works with LangChain · LlamaIndex · Vercel AI SDK · Streaming & Tool Calls
05 — Deploy
Zero-config single container serving both the React UI and Express gateway. No account, no database container, and no .env file required.
Run the unified image anywhere without cloning the repository. Reaches host Ollama on port 11434 out of the box.
$ docker run -d --name slir \ -p 4100:4101 -p 4101:4101 \ --add-host=host.docker.internal:host-gateway \ -e OLLAMA_URL=http://host.docker.internal:11434 \ -v slir_data:/app/data varad177/slir-app:latest
Includes persistent SQLite volume, healthcheck, log rotation, and optional SLIR_PUBLIC_BASE_URL / port overrides.
$ git clone https://github.com/varad177/SLIR.git && cd SLIR $ docker compose up -d
Or build locally: docker compose up -d --build
Run the Express gateway (:4101) and Vite dashboard (:4100) locally with hot reload.
$ npm install && npm run dev
$ npm install && npm run dev
06 — Architecture
A single Express gateway serves the built React dashboard, authenticates virtual application keys, translates OpenAI & Anthropic protocols, and writes metadata to SQLite.
Python, Node.js, .NET, Go, LangChain, cURL.
Ollama :11434 (native /api/chat + /v1)
LM Studio :1234 · vLLM :8000
OpenAI · Anthropic Messages
Groq · DeepSeek · custom /v1
SQLite (WAL · schema v5) — usage_events · custom_models · model_pricing · budgets · failover_trace · prompts never persisted
07 — Developer Reference
Every proxied response emits X-Request-ID and X-SLIR-Telemetry: recorded | skipped so you can verify attribution straight from your terminal.
OpenAI-compatible chat endpoint (SSE streaming, tools, vision, response_format). Resolves active-model, app pins, and failover chains.
Native Anthropic Messages ingress (x-api-key header). Translates requests, SSE deltas, tool use, and error shapes automatically.
Lists local Ollama inventory plus registered cloud custom endpoints with provider and format metadata.
Returns gateway and SQLite status; pass ?deep=1 to probe local Ollama dependency reachability.
Prometheus scrape endpoint exporting request counters, tokens, latency, spend, and failover metrics.
Internal Express listener serving the UI, management API, and /v1 gateway.
Local Ollama endpoint(s); comma-separated values are probed in order with health caching.
Embedded SQLite WAL database path persisted across restarts via Docker volume.
Automatic usage_events pruning window in days (0 keeps all telemetry forever).
Override snippet base URL when hosting SLIR behind a reverse proxy or domain.
Consecutive network/timeout/5xx errors before opening the per-model circuit breaker cooldown.
08 — FAQ
Built developer-first for fast local iteration and clean on-prem deployments. Open an issue on GitHub anytime.
Yes. It ships as one Docker container (varad177/slir-app:latest) with an embedded SQLite database. No account, no license key, and no telemetry leaves your machine. It runs offline on laptops, workstations, and on-prem servers.
SLIR stores operational metadata only: latency decomposition, token counts, routed model, HTTP status, failover trace errors, and calculated cost. Prompts and responses are never written to SQLite.
Use OpenAI SDKs at /v1/chat/completions or official Anthropic SDKs at /v1/messages (x-api-key). Route to Ollama, LM Studio, vLLM, LocalAI, OpenAI, Anthropic, Groq, DeepSeek, or any /v1 endpoint—with automatic OpenAI ↔ Anthropic translation for streaming, tool calling, vision, cache_control, and json_schema.
Send model: "active-model" from your app. SLIR resolves the alias against the active model (or per-application pinned model) in SQLite on every call. Change models in the browser and your very next request routes there without restarting your code.
Each application can configure up to five ordered fallback models. On HTTP 429, 5xx, timeout, network failure, or open circuit breaker, SLIR switches to the next healthy candidate and records a step-by-step attempt log (model, provider, HTTP status, duration, and error message) inspectable on both the Failover and Request Logs pages.
Create applications in the dashboard to generate mp_live_... virtual keys. Requests authenticated with an mp_live_ key are attributed to that app for analytics, budgets, and failover (returning X-SLIR-Telemetry: recorded). Unknown mp_live_ keys return 401; keyless local requests are proxied without recording telemetry (X-SLIR-Telemetry: skipped).
Configure versioned pricing rules or custom-model per-1M token rates, set daily or monthly notify/hard-block budgets per global, application, or model scope, and receive Slack/Discord webhook alerts or automatic HTTP 429 budget blocks at 100%.
MIT. Use it internally, self-host on-prem, fork it, or embed it in your stack. Source code is open on GitHub and images are public on Docker Hub.
Ready when you are
One container. No account. No prompts leaving your network. Run SLIR in seconds and point your OpenAI or Anthropic client at port 4101.
$ docker run -d --name slir -p 4100:4101 -p 4101:4101 \ --add-host=host.docker.internal:host-gateway \ -v slir_data:/app/data varad177/slir-app:latest