switchboard-router
Pick the cheapest LLM that can handle each prompt.
switchboard-router asks Switchboard, a 0.5B open router model, which tier a prompt needs: small, mid or frontier. Easy prompts go to a cheap model, and you pay frontier prices only when the prompt needs it.
pip install switchboard-router
Quickstart
You need one way to run the model. The easiest is Ollama: install it and leave it running. If the model isn't in Ollama yet, the first call pulls it (994 MB) from Hugging Face, which takes a minute or two. To do that ahead of time:
ollama pull hf.co/switchboardllm/switchboard-router-0.5b-GGUF
from switchboard_router import Router
router = Router() # uses Ollama when it's running
router.route("Write a haiku about rain").tier
# 'small'
router.pick_model("Unscramble the following words: eglar, ngareo, kobo")
# 'anthropic/claude-opus-5.5'
From the terminal:
switchboard "Design a rate limiter for 10M requests per second across 5 regions"
{"tier": "mid", "domain": "general", "valid": true, "model": "anthropic/claude-sonnet-5.5"}
Route, then call the model
pick_model returns a model id for the tier. By default these are Claude models on Surplus, which serves every model behind one OpenAI-compatible key:
from openai import OpenAI
from switchboard_router import Router
router = Router()
llm = OpenAI(base_url="https://api.surplusllm.com/api/v1", api_key="sk-surplus-...")
prompt = "Write a Python function that reverses a string"
reply = llm.chat.completions.create(
model=router.pick_model(prompt),
messages=[{"role": "user", "content": prompt}],
)
Use your own models per tier (give all three, or the rest fall back to the defaults with a warning):
router = Router(models={"small": "my/small-model", "mid": "my/mid-model", "frontier": "my/frontier-model"})
Backends
| Backend | Use it when | How |
|---|---|---|
ollama |
You run models locally | Router(backend="ollama") |
openai |
You serve the model with llama-server or vLLM, or call it on the Surplus API | Router(backend="openai", base_url="http://localhost:8080/v1", backend_model="switchboard") |
transformers |
You want it in-process | pip install 'switchboard-router[local]', then Router(backend="transformers") |
Router() with no backend uses Ollama if it's running, then Transformers if it's installed, and otherwise tells you what to install.
Failing safe
If the backend can't be reached, errors out, or the model's output isn't valid JSON, the decision is frontier with valid=False and the reason in decision.error. A failed routing call costs you money, never quality. With fail_safe=False, those cases raise instead. Empty or non-string prompts always raise ValueError or TypeError.
Requests time out after 15 seconds by default (Router(timeout=5) to change it), and redirects are not followed, so an API key is never sent to another host.
Limits
- The router reads the first 2,000 characters of a prompt. A question at the very end of a long prompt may be missed.
- It reads the prompt it's given, so a prompt can try to talk it into a cheaper tier. Don't use it as a security boundary.
How good is the routing?
Switchboard v0.1 on 10,000 held-out prompts: 64.5% cheaper than sending every prompt to Claude Opus 5.5, and 5.5% of prompts were sent to a cheaper tier than they needed. Method, limits and the full results are in the model card. Try it in your browser: Switchboard demo.
License
Apache-2.0.
Metadata
Release files for switchboard-router 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| switchboard_router-0.1.0.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| switchboard_router-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.5 kB
Release files / switchboard_router-0.1.0.tar.gz
| Download URL | switchboard_router-0.1.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a197d2039d552967cb40ca257246152c301b26f721f9d2309f47a3462506a498
|
|
BLAKE2b-256 checksum How to use checksums |
5d380bd91ebede3740589d64f3a7d4985e4f483a7d9043d7504949ed8b10f190
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.0
|
Release files / switchboard_router-0.1.0-py3-none-any.whl
| Download URL | switchboard_router-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2871880e356e83993fb92d9a85c095d741d425f1aa2a27ccedde4ee715aed0aa
|
|
BLAKE2b-256 checksum How to use checksums |
fe51fbdc76bb81fb5b12bbe4cdf13101ad15ffc1a903954f2a921f066d54b22b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.0
|