Configuration
LARouter is configured through environment variables, a JSON config file, and runtime API.
Environment Variables
Required (at least one API key)
| Variable | Description | Example |
|---|---|---|
OPENAI_API_KEY | OpenAI API key | sk-... |
ANTHROPIC_API_KEY | Anthropic API key | sk-ant-... |
GOOGLE_API_KEY | Google Gemini API key | AIza... |
DEEPSEEK_API_KEY | DeepSeek API key | sk-... |
[!IMPORTANT] At least one API key must be configured. For local-only operation with Gemma 4 models, set any key to a dummy value (e.g.,
GOOGLE_API_KEY=local-only).
Optional
| Variable | Default | Description |
|---|---|---|
LAROUTER_PORT | 18790 | Server port |
LAROUTER_HOST | 127.0.0.1 | Bind address |
LAROUTER_ADMIN_KEY | (generated) | Admin API key for dashboard auth |
LAROUTER_LOG_LEVEL | info | Logging level: debug, info, warn, error |
LAROUTER_DB_PATH | ./larouter.db | SQLite database path |
LLAMA_CPP_PATH | /usr/local/bin | Path to llama.cpp binaries |
Custom Provider URLs
| Variable | Default | Description |
|---|---|---|
LAROUTER_OLLAMA_URL | http://localhost:11434 | Ollama server |
LAROUTER_LLAMACPP_URL | http://localhost:8001 | llama.cpp server |
LAROUTER_CUSTOM_URL | — | Any OpenAI-compatible endpoint |
Config File
backend/config/default.json — default tier mappings and model configuration:
{
"tiers": {
"HEARTBEAT": {
"model": "gemma-4-e2b",
"provider": "llamacpp",
"maxTokens": 256
},
"SIMPLE": {
"model": "gemma-4-e4b",
"provider": "llamacpp",
"maxTokens": 1024
},
"MODERATE": {
"model": "gemma-4-26b-a4b",
"provider": "llamacpp",
"maxTokens": 4096
},
"COMPLEX": {
"model": "gemini-2.5-pro",
"provider": "google",
"maxTokens": 8192
},
"FRONTIER": {
"model": "claude-opus-4",
"provider": "anthropic",
"maxTokens": 16384
}
},
"classifier": {
"aiThreshold": 0.7,
"aiTimeout": 3000,
"aiModel": "gemma-4-e2b"
},
"escalation": {
"enabled": true,
"maxRetries": 2,
"retryDelay": 1000
}
}
.env.example
# ─── API Keys (at least one required) ───────────
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GOOGLE_API_KEY=
DEEPSEEK_API_KEY=
# ─── Server ─────────────────────────────────────
LAROUTER_PORT=18790
LAROUTER_HOST=127.0.0.1
LAROUTER_ADMIN_KEY=
# ─── Local Models ───────────────────────────────
LLAMA_CPP_PATH=/usr/local/bin
LAROUTER_OLLAMA_URL=http://localhost:11434
# ─── Logging ────────────────────────────────────
LAROUTER_LOG_LEVEL=info
LAROUTER_DB_PATH=./larouter.db
Runtime Configuration API
Update configuration without restarting:
# View current config (keys redacted)
curl http://127.0.0.1:18790/api/config
# Update tier mapping
curl -X PATCH http://127.0.0.1:18790/api/config \
-H 'Content-Type: application/json' \
-d '{"tiers": {"SIMPLE": {"model": "gemma-4-26b-a4b"}}}'
Per-Project Overrides
Each project can override the global tier mapping:
{
"name": "my-app",
"routingPolicy": "cost-optimized",
"tierOverrides": {
"COMPLEX": {
"model": "gemini-2.5-flash",
"provider": "google"
}
},
"budgetUsd": 50.0
}
Available routing policies:
| Policy | Behavior |
|---|---|
balanced | Default — use tiers as configured |
cost-optimized | Prefer local models, only escalate when necessary |
quality-optimized | Prefer cloud models for all non-trivial tasks |
local-only | Never use cloud APIs |