ArticleJuly 25, 2026

OpenRouter’s Two-Layer Routing System

OpenRouter is a service that I really appreciate. What they do is essentially address two issues: which AI model should be used to handle this request (Model Routing), and which provider should be chosen to run this model (Provider Routing). These two issues are decided separately. Why? In the past, when using GPT, we would turn to OpenAI; when using Claude, we would turn to Anthropic, because the models and providers were tied together. But with OpenRoute…

OpenRouter is a service that I really appreciate. What they do is essentially address two problems:

Which AI model should be used to handle this request? And which service provider should be chosen to execute this model? (Model Routing)

These two issues are decided separately. Why?

In the past, when using GPT, people would turn to OpenAI; when using Claude, they would go to Anthropic. This was because the models and service providers were connected together. But with OpenRouter, there are over seventy different service providers available. For the same model, especially open-source models, it’s common for several providers to offer it. Therefore, choosing a model and choosing a service provider become two separate processes.

Let’s start with the aspect of model selection.

The simplest way to do this is to clearly specify which model you want to use in your request. For example, you can write “Claude Sonnet”. In this case, OpenRouter won’t make any choices for you. It will only determine which service provider should be used to implement this model, and how to handle any potential issues that arise.

If you don’t want to decide which model to use on your own, you can rely on its Auto Router function. Just write “openrouter auto” as the command. It will analyze the content of your question and automatically select the appropriate model to use in providing an answer.

The automatic model selection relies on technology from a company called Not Diamond. You can set how much you prioritize quality or cost with a slider from zero to ten. Lower numbers favor more powerful models, higher numbers favor lower cost, and the default is seven. You can also limit the selection to models from Anthropic and OpenAI, for example.

Don’t worry, this automatic model selection feature is free of charge. The cost is only applied based on the model that is actually selected by the user.

There’s another more convenient approach: simply create a list of models with predetermined priorities. For example, start with Claude as the preferred choice. If it doesn’t work, then try the GPT small model. If that still doesn’t work, then consider Gemini. As long as the preferred model encounters issues like traffic limits, downtime, or content censorship, the system will automatically switch to the next available model without you having to write any code to handle these exceptions. In this way, you only pay for the model that is actually used.

As for choosing a service provider, this is the most detailed and sophisticated aspect of OpenRouter’s functionality.

When you don’t set any preferences, it will first consider which service providers have not experienced any significant failures over the past thirty seconds. Those that are unstable will be ranked lower, and may even be eliminated altogether. Then, among the remaining stable service providers, it will prefer those that offer cheaper prices. However, it doesn’t simply choose the cheapest provider. Instead, it makes a weighted distribution based on price, so that the cheaper options get more points, while still leaving room for others. The remaining providers are kept as backups in case of emergencies.

So, the default strategy isn’t simply about finding the cheapest option. Instead, it focuses on ensuring reliability first, while also considering cost-effectiveness.

Member only

Continue reading the full article

Sign in as a member or explore membership options.