Skip to main content

Configuration

LARouter is configured through environment variables, a JSON config file, and runtime API.

Environment Variables

Required (at least one API key)

VariableDescriptionExample
OPENAI_API_KEYOpenAI API keysk-...
ANTHROPIC_API_KEYAnthropic API keysk-ant-...
GOOGLE_API_KEYGoogle Gemini API keyAIza...
DEEPSEEK_API_KEYDeepSeek API keysk-...

[!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

VariableDefaultDescription
LAROUTER_PORT18790Server port
LAROUTER_HOST127.0.0.1Bind address
LAROUTER_ADMIN_KEY(generated)Admin API key for dashboard auth
LAROUTER_LOG_LEVELinfoLogging level: debug, info, warn, error
LAROUTER_DB_PATH./larouter.dbSQLite database path
LLAMA_CPP_PATH/usr/local/binPath to llama.cpp binaries

Custom Provider URLs

VariableDefaultDescription
LAROUTER_OLLAMA_URLhttp://localhost:11434Ollama server
LAROUTER_LLAMACPP_URLhttp://localhost:8001llama.cpp server
LAROUTER_CUSTOM_URLAny 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:

PolicyBehavior
balancedDefault — use tiers as configured
cost-optimizedPrefer local models, only escalate when necessary
quality-optimizedPrefer cloud models for all non-trivial tasks
local-onlyNever use cloud APIs