Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Router Configuration

The inference router selects which model backend handles each agent request.

Basic setup

[router]
default_route = "local"

[[router.routes]]
name = "local"
provider = "ollama"
model = "llama3.2"
base_url = "http://127.0.0.1:11434"

[[router.routes]]
name = "cloud"
provider = "anthropic"
model = "claude-sonnet-4-20250514"
api_key = "${ANTHROPIC_API_KEY}"

Route selection

The router picks a route based on:

  1. Agent hint — The agent can request a specific model via infer_with_model.
  2. Route profile — Weighted selection based on configured thresholds.
  3. Default route — Falls back to default_route if no match.

Route profiles

Fine-tune routing behavior per agent:

[[agents]]
name = "researcher"

[agents.route_profile]
prefer = "cloud"
fallback = "local"
max_latency_ms = 5000
cost_weight = 0.3
quality_weight = 0.7
FieldDescription
preferPreferred route name
fallbackRoute to use if preferred is unavailable
max_latency_msSwitch to fallback if latency exceeds this
cost_weightWeight for cost optimization (0.0-1.0)
quality_weightWeight for quality optimization (0.0-1.0)

Provider reference

Providerprovider valueRequired fields
Ollamaollamabase_url, model
Anthropicanthropicapi_key, model
OpenAI-compatibleopenaibase_url, api_key, model

Testing routes

Verify routing with:

akshi config-check --test-routes

This sends a test prompt to each configured route and reports latency and availability.