model field in your request. The endpoint and API key stay the same; only the model value changes.
How routing works
Each deployment has a unique public name. When Tokios receives a request, it reads themodel field, finds the deployment with that name, rewrites it to that deployment’s upstream model id, and forwards it down the connector’s tunnel. Your client config never changes — only the model value.
One connector, many models
A single connector can serve several models. List each upstream model id inRoutes and map it to a named local upstream in Upstreams:
tokios-connector.json
gemma-tunnel → gemma4:e4b, qwen-coder → qwen2.5-coder), all pointing at this connector.
Switching models in requests
With both deployments registered, switch models by changing only themodel field:
Swap the backend without touching clients
Because clients only reference the public name, you can move a model to different hardware or a different backend without changing any client config: update the deployment (or the connector’s upstream) to point at the new server, keep the same public name, and existing requests keep working.Routing strategies
When you run multiple local models, sending every request to the same model wastes resources. A coding request doesn’t need a 120B reasoning model, and a simple classification task doesn’t need a 70B dense model. Routing lets you direct each request to the model best suited for the task — optimizing for speed, quality, or cost depending on the workload. Running 1 model for everything forces a trade-off. A large model handles every task well but responds slowly and consumes more VRAM. A small model responds fast but struggles with complex reasoning. Routing lets you have both:- Speed: simple queries go to a small, fast model; complex tasks go to a large model
- Quality: code tasks go to a code-specialized model; general chat goes to a generalist
- Cost: smaller models consume less power and VRAM, leaving headroom for demanding tasks
- Resilience: if your primary model is busy or down, requests fall through to a backup
Single model per deployment
Single model per deployment
The simplest approach — register each model as its own Tokios deployment and let the client choose which to call by changing the Your client sends requests with the appropriate When to use: you run 2–3 models and your application controls which model to call. This is the most common starting point.
model field.tokios-connector.json
model value:Task-based routing
Task-based routing
Route by task type — send coding requests to a code-specialized model, chat to a generalist, and reasoning to a dense model. The client or a middleware layer inspects the request and picks the deployment.For more sophisticated routing, use a gateway like LiteLLM or OpenRouter that inspects requests and forwards to the correct backend based on configurable rules.
The simplest implementation is in your application code — inspect the request type and select the deployment name:
Gateway-level routing
Gateway-level routing
Place a routing proxy between your clients and Tokios. The proxy decides which Tokios deployment to use based on request attributes, load, or custom rules.LiteLLM can sit in front of multiple Tokios deployments and route based on model aliases:Clients send requests to the LiteLLM proxy using the alias
litellm_config.yaml
gpt-4, and the proxy routes to whichever Tokios deployment you configured.OpenRouter supports model fallback and load balancing across multiple providers. Add your Tokios endpoint as a custom provider and configure routing rules in the OpenRouter dashboard.Fallback chains
Fallback chains
Configure a primary model with 1 or more fallback models. If the primary is busy, offline, or returns an error, the request falls through to the next model in the chain.Tokios connectors report their status to the gateway. If a connector goes offline, requests to deployments on that connector return 503. Your application can catch this and retry with a different deployment, or you can configure a gateway like LiteLLM to handle the fallback automatically.
Cost-based routing
Cost-based routing
Route simple, high-volume requests to a smaller, cheaper model and reserve the large model for tasks that need it.
This strategy reduces total compute and power consumption — important when running on consumer hardware where VRAM and wattage are limited.
Decision matrix
These strategies are not mutually exclusive. A common production pattern combines task-based routing (code → code model) with fallback chains (primary → backup) behind a gateway proxy.
Next steps
Choose a local model
Compare models and backends to decide which deployments to register.
Benchmark your deployment
Measure throughput and latency to validate your routing decisions under real workloads.