Provider-agnostic LLM call_tool router with yaml routing, fallback chains, and cost telemetry.
Project description
llm_router →

Provider-agnostic LLM router with YAML routing, auto-failover, cost telemetry, and multi-model support.
One API. Any provider. Zero vendor lock-in.
llm_router is a small Python package (~500 LOC core) that gives you a uniform call_tool() interface across Anthropic, DeepInfra, OpenRouter (30+ models), and more. Define routing rules in YAML — change providers without touching application code. In production since May 2026 powering second-brain-instance.
Why llm_router?
- 🔀 Multi-provider by default — Anthropic, DeepInfra, OpenRouter. Add more via config.
- 🛡️ Auto-failover — provider down? Router switches to fallback automatically (circuit breaker)
- 💰 Cost-aware — route to cheapest available model. Daily budget guard.
- 📊 Telemetry built-in — every call logged (provider, model, tokens, cost, latency)
- 📝 YAML-only config — change routing rules without touching code
- 🇵🇱 Polish-optimized — routing rules aware of PL language quality per model
- 🧩 Drop-in — replace direct
anthropicSDK calls withcall_tool(use_case=..., ...)
Quick Start
pip install llm-router
from llm_router import call_tool, set_routing_config
# One-time setup (put in your app's __init__)
set_routing_config('config/llm_routing.yaml')
# Use anywhere — same API regardless of provider
result, usage = call_tool(
use_case='myapp.feature_x',
system='You are a helpful assistant.',
user='Summarize this text: ...',
schema={'name': 'summarize', 'input_schema': {...}},
)
print(f'${usage.cost_usd:.4f} via {usage.provider}/{usage.model}')
Full walkthrough: docs/INTEGRATION.md (5 min).
Configuration
# config/llm_routing.yaml
providers:
deepinfra:
api_key_env: DEEPINFRA_API_KEY
default_model: Qwen/Qwen3.5-397B-A17B
openrouter:
api_key_env: OPENROUTER_API_KEY
base_url: https://openrouter.ai/api/v1
anthropic:
api_key_env: ANTHROPIC_API_KEY
use_cases:
myapp.feature_x:
primary: { provider: deepinfra, model: Qwen/Qwen3.5-397B-A17B }
fallback:
- { provider: openrouter, model: qwen/qwen3.5-397b-a17b }
- { provider: anthropic, model: claude-haiku-4-5-20251001 }
cost_stop_per_call_usd: 0.50
Status
✅ In production — routing all LLM calls for second-brain-instance since May 2026.
- 30+ calls/day across 11 perspective types
- DeepInfra Qwen primary, OpenRouter fallback, Anthropic last resort
- Provider error rate monitored with auto-failover (R4 — in progress)
Documentation
docs/INTEGRATION.md— 5-min quick-startdocs/ARCHITECTURE.md— design, provider protocol, error handlingdocs/IMPLEMENTATION_PLAN.md— roadmap, tasks
Decision history:
Strategy:
docs/router-strategy-analysis.md— full strategic analysis: requirements, market, RICE prioritization, cost, cross-domain expansion
License
MIT © 2026 Eryk Orłowski
Built for second-brain-instance — now open to everyone.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exocortex_llm_router-0.1.1.tar.gz.
File metadata
- Download URL: exocortex_llm_router-0.1.1.tar.gz
- Upload date:
- Size: 197.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f630492a7005b6cd729453a5520f17091f62959a70c4de0f9f41b500eb04003b
|
|
| MD5 |
ced198626b90a88139a1d0dac8984ac4
|
|
| BLAKE2b-256 |
347a2a1a34116497f09e291bd4e5e7d68e38775793bf899b69d09c442609e9b8
|
Provenance
The following attestation bundles were made for exocortex_llm_router-0.1.1.tar.gz:
Publisher:
publish.yml on hretheum/router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exocortex_llm_router-0.1.1.tar.gz -
Subject digest:
f630492a7005b6cd729453a5520f17091f62959a70c4de0f9f41b500eb04003b - Sigstore transparency entry: 1629240616
- Sigstore integration time:
-
Permalink:
hretheum/router@61634d2736b55ea32f88bab157efc317a895c088 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hretheum
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@61634d2736b55ea32f88bab157efc317a895c088 -
Trigger Event:
push
-
Statement type:
File details
Details for the file exocortex_llm_router-0.1.1-py3-none-any.whl.
File metadata
- Download URL: exocortex_llm_router-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bba058257f6ed8c78d95e396df78a791eb3d5883b6c2c8c121287305a482d93f
|
|
| MD5 |
1bea23c91d214fd677fddf9369ed19c6
|
|
| BLAKE2b-256 |
b94bb8c01c884a72f288d789011c24234a0d2d436d709df160c72dcecd404635
|
Provenance
The following attestation bundles were made for exocortex_llm_router-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on hretheum/router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exocortex_llm_router-0.1.1-py3-none-any.whl -
Subject digest:
bba058257f6ed8c78d95e396df78a791eb3d5883b6c2c8c121287305a482d93f - Sigstore transparency entry: 1629240631
- Sigstore integration time:
-
Permalink:
hretheum/router@61634d2736b55ea32f88bab157efc317a895c088 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hretheum
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@61634d2736b55ea32f88bab157efc317a895c088 -
Trigger Event:
push
-
Statement type: