Auto routing
Match requests to models and save on costs
Simple requests are those that use a simple model.
If we write “alprouter/auto” under model, we can report the difficulty level of each request, and then send the appropriate model to it. This way, we don’t need to use the most expensive model for simple requests. As a result, costs are reduced.
client.chat.completions.create(
model="alprouter/auto",
messages=[{"role": "user", "content": "Hello"}],
# Only set this to restrict model selection
extra_body={"plugins": [{"id": "auto-router", "allowed_models": ["anthropic/*", "openai/*"]}]},
)| Steps | Such requests | First, the models that are selected for selection. |
|---|---|---|
| Simple | Hello, classification, brief translations. | GPT-6 Luna |
| Everyday | Summary: Email, small functions | Claude Haiku 5.5 |
| Advanced | Finding bugs, various stages of analysis | Claude Sonnet 5.5 |
| Expert | System design, verification | Claude Opus 5.5 |
Fees
- The fees are only based on the price of the chosen model. No additional fees will be charged.
- The answer model can be seen in the response of
model. - How it was chosen is indicated in the response for
router.tierrepresents the level of difficulty (1 – simple, 2 – average, 3 – difficult, 4 – professional).judged_tiershows the result of the difficulty assessment.classifiershows the model and token scores used in the evaluation.methodsindicates the method used. The tools used aretextandtool. If we need to estimate the usage, thenusage_estimatedwill be enabled. modecan be classified astierif it’s in a step-by-step mode,floorif it’s in a saving mode, andbalancedif it’s in a balanced mode. If a decision is skipped or fails, thenreasonis the reason for that.attemptsrepresents the number of times the question has been asked, whilefallbacksrepresents the number of times it has been transferred to another connection.- In the console’s usage history, if you click on the “Requests” tab, you can see information about how the requests were selected.
- In the stream, if a request is made, then there’s a piece of data containing information about the last usage. If no request is made, then there’s a piece of data containing information about the end of the response. This information is represented by
router. - In the
/responsesstream, it can be found in theresponse.routerof the last event. - In the console home page, it shows how much money was saved based on the actual number of tokens used. When comparing, the price of the highest level model that could be used is taken into account.
Energy-saving mode
If I write “alprouter/auto:floor” under “model”, I will only choose from those models that have good answers compared to their prices. There’s no way to determine the difficulty level, so the waiting time never increases. I really like tasks that involve a lot of questions and answers, as well as tasks that require classification and reading before answering.
- Based solely on the content of the request, I will send it to the model that best suits the job at a reasonable price.
- The request to write a long text can increase the cost. If the priority is to find the cheapest option, then please write the model directly or narrow down the range with
allowed_models. - When one of the models is blocked, another model in the bundle takes over. When it’s not possible to use the bundle, then the usual automatic selection method is used.
- The model that spends a long time thinking reduces the number of thoughts it has. When you enter
reasoning_effort, it will use that value as the basis for its calculations. - In the response of
router, it is indicated thatmodeis equivalent tofloor, and the name of the rule applied toruleis also mentioned.
Balanced Mode
If we write “alprouter/auto:balanced” under model, it works in the same way as the “efficiency mode”. However, for general questions, a more accurate model will provide better answers. This is especially useful for difficult objective or knowledge-based questions, where accuracy is important. There’s no step of evaluating the difficulty level, just like in the “efficiency mode”.
- While the more accurate answers are available in the “savings mode,” the cost is higher. If you need to get many short answers, then the “savings mode” is more cost-effective.
- When the regular model fails, the “savings mode” model takes over. It will call
reasoning_effortwith the values that correspond to that value. - In the response of
router,modeis written asbalanced.
Changing the way of selection
| Options | What they do |
|---|---|
allowed_models | You can only select from this model. You can use asterisks, just like in “anthropic/”. |
excluded_models | This model isn’t uniform. |
short_requests | When set to “floor”, short requests are sent in a compressed mode. Initially, it’s turned off. |
cost_tier | If you choose “low”, it will be one level lower. If you choose “high”, it will be one level higher. |
- It can be set to
plugins: [{ id: "auto-router", short_requests: "floor" }]. This option is applicable when the user’s post contains only one piece of content, and the length of that content is less than 1,000 characters. The system allows sending multiple items together. If there are previous replies, tools, images, orresponse_formatavailable, then it’s selected using the standard method. - Regardless of the stage at which it’s sent, as long as the connection between the models is the same, the level of difficulty can be skipped.
- It takes about 0.7 seconds to choose a choice. If the user cannot determine the difficulty level, they will be sent to the third level.
- If you send both the tool and
response_format, then it will be selected within the model that receives that item. - If other models are listed under
models, then when a model with a uniform model is blocked, it will be switched to that model instead.