Skip to content
SLIR

SLIR · Switch LLM In Runtime·Self-Hosted AI Gateway

One local AI gateway.Switch LLMs at runtime.

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.

1-Click Hot-SwapOpenAI + Anthropic APIAuto Failover TracesMIT · Zero Prompts Stored
run anywhere with docker (zero config)
$ 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)
SLIRLIVE DEMO
GATEWAY :4101
1 · Client app (unchanged)0 restarts
client.chat.completions.create(model="active-model")
2 · Switch route target at runtimePinned model
3 · Live gateway traceHTTP 200 · X-SLIR-Telemetry: recorded
1. Client requestmodel: "active-model" → nomic-embed-text:latest
2. Response delivered200 OK · 0.32s · 612 tokens

Indexed 612 prompt tokens locally at $0 cost.

L:0msPE:42msG:148.2 tok/sCost:$0.0000
Live interactive dashboard preview — try switching models & testing failover
http://localhost:4100
SLIRSWITCH RUNTIME
:4101 Live
SLIR/OverviewGlobal: google/gemma-4-31b-it
MODEL ROUTING
Your App

Requests sent with this application key are routed by the rule below.

Pinned modelnomic-embed-text:latestOllama
http://localhost:4101/v1
RUNTIME DEFAULTSCONTEXTTEMPERATURE
Applies to requests that do not send their own values.
REQUESTS83.3% success
6
5 succeeded1 failed
TOKENS91% in
4,820
4,380 prompt440 comp.
TOKEN VOLUME
PROMPT CACHE33% hit
2
6 reportedL:0.04s
ESTIMATED SPENDtracked
$0.0042
$0.00/day~$0.13/30d
LATEST ACTIVITY
RECENT REQUESTS
gpt-4o-miniFailover200
Your App · 16:56:41980 ms · 412 tok
from claude-sonnet-4 · Rate limit ·
nomic-embed-text:latest200
Your App · 16:54:12320 ms · 612 tok
google/gemma-4-31b-it200
support-bot · 16:50:081.14s · 940 tok
Works withOllama·LM Studio·vLLM·LocalAI·OpenAI·Anthropic Claude·Groq·DeepSeek·any /v1 endpoint

01 — Why SLIR

Stop restarting your backend to test a model.

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.

01before

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.

02before

The latency mystery

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.

03before

The cost & token blind spot

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.

04before

The single point of failure

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.

Zero .env requiredSingle Docker containerOpenAI + Anthropic SDKsPrompts never stored

02 — Capabilities

A complete local AI control plane.

Everything developers end up duct-taping together around local and cloud LLMs—packaged into a single zero-config container.

Runtime model switching

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"

Latency X-ray profiler

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

OpenAI & Anthropic APIs

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

Automatic failover traces

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

Cost rules, budgets & alerts

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

Filterable request logs

Filter by app, model, status, stream, or routing outcome (Failover only/succeeded/failed), inspect cURL/JSON, and export CSV.

X-SLIR-Telemetry header

Live streaming playground

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

SQLite WAL privacy-first

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

See exactly where the milliseconds go.

Most tools tell you a request took three seconds. SLIR breaks it into the three phases that actually explain why.

  • Model load

    VRAM weight and KV cache initialization. The badge tells you cold load versus resident warm.

  • Prompt eval

    Time to first token. The real cost of a large context window, measured before generation starts.

  • Eval

    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.

Probe resultcold load
3.00sqwen2.5:7b · 4K ctx · temp 0.3
Model load
470ms
TTFT
174ms
Generation
67.8 tok/s

Eval time 2.36s · 160 tokens out

Context windownum_ctx
0.3
Cache statecold vs warm

03 — Integration

Keep your OpenAI or Anthropic SDK.

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)

Checks X-SLIR-Telemetry: recorded · Works with LangChain · LlamaIndex · Vercel AI SDK · Streaming & Tool Calls

05 — Deploy

Running in under a minute.

Zero-config single container serving both the React UI and Express gateway. No account, no database container, and no .env file required.

Docker 24+amd64 & arm64 multi-archNode 22+ for source builds
01fastest

Single Docker container

Run the unified image anywhere without cloning the repository. Reaches host Ollama on port 11434 out of the box.

shell
$ 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
02compose

Docker Compose

Includes persistent SQLite volume, healthcheck, log rotation, and optional SLIR_PUBLIC_BASE_URL / port overrides.

shell
$ git clone https://github.com/varad177/SLIR.git && cd SLIR
$ docker compose up -d

Or build locally: docker compose up -d --build

03Node 22+

From source

Run the Express gateway (:4101) and Vite dashboard (:4100) locally with hot reload.

backend/
$ npm install && npm run dev
frontend/
$ npm install && npm run dev
Dashboard UI
http://localhost:4100
AI Gateway
http://localhost:4101/v1
Docker Image
varad177/slir-app:latest
SQLite Volume
ai_monitor_sqlite_data

06 — Architecture

One process between your app and every model.

A single Express gateway serves the built React dashboard, authenticates virtual application keys, translates OpenAI & Anthropic protocols, and writes metadata to SQLite.

Client apps
OpenAI or Anthropic SDK

Python, Node.js, .NET, Go, LangChain, cURL.

base_url:4101/v1
api_keymp_live_...
modelactive-model
Unified Container
:4100 / :4101
SLIR Gateway + UInode 22
  • Dynamic model resolver (active-model / pinned)
  • OpenAI ↔ Anthropic bidirectional translation
  • Latency + usage + failover trace writer
  • Per-app budget hard-block & webhooks
Upstreams
Local + cloud runtimes
local

Ollama :11434 (native /api/chat + /v1)
LM Studio :1234 · vLLM :8000

cloud

OpenAI · Anthropic Messages
Groq · DeepSeek · custom /v1

SQLite (WAL · schema v5) — usage_events · custom_models · model_pricing · budgets · failover_trace · prompts never persisted

Single Node.js + SQLite processZero prompt or completion retentionBuffered & full SSE streaming telemetry

07 — Developer Reference

Every endpoint & flag in one view.

Every proxied response emits X-Request-ID and X-SLIR-Telemetry: recorded | skipped so you can verify attribution straight from your terminal.

HTTP Endpoints

:4101
POST/v1/chat/completions

OpenAI-compatible chat endpoint (SSE streaming, tools, vision, response_format). Resolves active-model, app pins, and failover chains.

POST/v1/messages

Native Anthropic Messages ingress (x-api-key header). Translates requests, SSE deltas, tool use, and error shapes automatically.

GET/v1/models

Lists local Ollama inventory plus registered cloud custom endpoints with provider and format metadata.

GET/api/health?deep=1

Returns gateway and SQLite status; pass ?deep=1 to probe local Ollama dependency reachability.

GET/api/metrics

Prometheus scrape endpoint exporting request counters, tokens, latency, spend, and failover metrics.

Environment Variables (Optional)

zero-config defaults
PORT4101

Internal Express listener serving the UI, management API, and /v1 gateway.

OLLAMA_URLhttp://host.docker.internal:11434

Local Ollama endpoint(s); comma-separated values are probed in order with health caching.

DATABASE_PATH/app/data/monitor.db

Embedded SQLite WAL database path persisted across restarts via Docker volume.

RETENTION_DAYS0

Automatic usage_events pruning window in days (0 keeps all telemetry forever).

SLIR_PUBLIC_BASE_URL(auto-detected)

Override snippet base URL when hosting SLIR behind a reverse proxy or domain.

FAILOVER_CIRCUIT_FAILURES5

Consecutive network/timeout/5xx errors before opening the per-model circuit breaker cooldown.

08 — FAQ

Questions developers actually ask.

Built developer-first for fast local iteration and clean on-prem deployments. Open an issue on GitHub anytime.

Is SLIR really self-hosted?

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.

Do my prompts or completions leave the machine?

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.

Which SDKs, protocols, and providers are supported?

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.

How does runtime model switching work?

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.

How do automatic failover and failover logs work?

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.

How do application keys and telemetry headers work?

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).

How are costs, budgets, and alerts tracked?

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%.

What is the license?

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

Your stack. Your models. Your telemetry.

One container. No account. No prompts leaving your network. Run SLIR in seconds and point your OpenAI or Anthropic client at port 4101.

terminal
$ 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