role-model: the case for a model routing protocol
2026-06-26
Github: https://github.com/try-works/role-model
Docs: https://role-model.dev/
Is the future of AI local, that we'll all be running models on our laptops and smartphones, or cloud, with large expert models run centrally dominating our usage? It's neither, or both, because the future is hybrid. Every day, we'll be running thousands of background processes that access an inference service at some point, totally out of sight and out of mind. These will be core processes of any application, and the number of use cases for inference processes is unbounded.
At times, workloads will be simple and latency or cost a priority, other times accuracy will be prized. In the first case, developers will be able to access a small, local model running on the users' devices that they can basically requisition for free (see Google WebLLM for which they now package a 4gb model with Chrome, and of course Apple's Foundation Models and routing in macOS 27). In the second case, a large generalist cloud model might be the best choice, but it could also be a small-ish specialist model that is preferred. These different workloads will exist within the same application, running on the same device, and the choice of models has to be blindingly fast, accurate and unobtrusive to the user. That means routing between models based on a set of factors.
My first attempt at building the foundation of this future is
role-model: a model routing protocol, a router runtime, and a package for Pi that allows the agent to classify requests for more accurate routing, pi-role-model.
Routing is all about making decisions, and making decisions requires information. role-model allows for assigning models and endpoints to roles, which have a defined set of related tasks and capabilities, and then routing based on a mixed set of factors: built-in benchmark data for the model and endpoint (the same model does not perform the same across providers), declared capabilities, observed capabilities and performance, preferences for either sides of the triangle of constraints, quality-cost-speed, and of course by role and task.
Some of this data can be collected and built up over time, but in many cases some vital decision-making data is missing. Consumer applications do not classify their inference requests, for example by task or role, and inference providers do not accept requests with such classifications.
That's where the role-model router runtime comes in, and the pi-role-model package. With pi-role-model, Pi can classify the requests it send to role-model by required capabilities, role (such as researcher or coder or planner) and task (
coder.review). This way, routing decisions can be made more accurate than before, provided that roles and capabilities are accurately configured.
What you'll probably realize here is that getting the role right is pretty hard, because what we're really doing right now is choosing between a group of generalist models, whether its GPT or DeepSeek or Kimi. None of them are really designed to excel at any certain thing. So as an aside, the ability to make informed and accurate routing decisions opens the door for more specialized models, and can help turn training specialized models into a real viable business. But for now, let's get back to the headline and make the case for model routing from a diverse set of perspectives.
For software developers
As a developer I would appreciate being able to call a model for simple things like semantic matching or classification, but I don't really feel like running the calculations on the ROI of this basic capability or pay for it. I'd prefer I could just use an on-device model on the devices of my users, making the feature effectively free.
I'd also prefer not to have to benchmark every potential model in existence for every possible task in my app, and also to not choose the most capable, expensive model just to defensively ensure that hallucinations don't leak back out to the user.
If I could call a router endpoint (or cloud gateway) that defines task, capabilities and modalities, and have my request routed to a suitable model based on benchmark data, observed endoint data and such, and simply consumer the return in my application, that would make my life a lot easier, and applications much more powerful.
Today, most applications that leverage inference already have some form of crude routing built in, but it is often rough and imprecise, all built on different logic and far from achieving the full benefits of intelligent model routing.
For users
Applications like Figma and Paper are adding powerful new AI-backed features but they consume a lot of tokens that are charged at a very high price. As a user, I would prefer to not just BYOK but to connect applications to my own router so that I not just provide my own inference, but a pool of models to be routed through for improved cost/performance.
I could run a Qwen 35BA3B as a local model for tool calling, instruction following and such, GPT 5.5 for really hard tasks and DeepSeek V4 for the vast quantity of middle-ground requests. This would let me cut application inference costs by probably 90%.
For inference providers
The lifespan of GPUs for serving frontier models is supposedly around three years after which they are not competitive and Nvidia will actually buy back the racks of now outdated chips from their customer datacenters.
With precise model routing we for the first time get a truly differentiated inference market across the triangle of constraints: speed, cost, and quality.
You can easily imagine, for example, next-gen models that are not bigger and better, but smaller, faster and about as capable as previous-gen models, running on older inference systems and selling for significant disounts per token vs a frontier model.
You can also have model and inference plans that clearly differentiate on quality as well, and even specialist models per domain.
For labs
Once you have a model router up and running you realize two things:1) It's hard to make routing decisions between two or more generalist models, and
2) The more differentiated the pool of models is, the easier routing decisions become, and so does the performance increase
Model routing therefore creates a market for differentiated, specialist models: one for prose, another for code, a third for research, a fourth for math and a fifth for biotech.
Specialist models will outperform generalist models on their own category of tasks, can potentially be cheaper and/or faster thanks to being smaller.
For device makers
Packaging models with laptops and smartphones will let application access near free, low latency inference and potentially offer users a better experience with the option of preserving data on-device. This is viable under the condition that tasks that do require larger expert models that run in the cloud can be routed to external models.
A side-effect of local models and what will let Apple cut upgrade cycles from ~4 years (?) down to 12-18 months is specialized hardware to run them. For almost a decade, smartphones have been trying to compete on better cameras. This coming decade will see them selling better GPUs, NPUs, ASICs and whatever other things they'll be calling the inference chips, to drive re-purchase. Every six months will see a better model on new hardware, which will enable better performance in certain applications.
How role-model makes decisions
In the ideal case, we want the consumer application that sends the requests to define the request type: what is the domain (code, prose, research, etc), what capabilities and modalities are needed, and what level of complexity is the request estimated to be at.With this information together with model and endpoint metadata that exists within the role-model router runtime we can match the request to a model based on a large range of factors like: roles assigned to models and their corresponding tasks, cost per token, observed latency, benchmark performance for different difficulty levels and so on.In an upcoming release, role-model will also use evals for previously seen requests to enrich model profiles and decision making.
Start routing with role-model
I released the role-model router runtime in an alpha version just a couple of days ago! The router is a middleware between your inference providers and your inference consumer applications and allows you to set up routing strategies based on your preferences. You can for example set up a model pool of GPT 5.5 and DeepSeek V4 Pro and connect Pi or OpenCode to the role-model endpoint (127.0.0.1:3456), set the model id to difficulty.remote-only and you're good to go. That should make your Codex quota last a lot longer.
Simply hand the Github URL or the image below to your agent and it will set it up for you.
You can also take a look at Github and implement the role-model routing protocol in your application to enable role-model to make more accurate routing decisions.