Skip to content
Docs ·Auto routing

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/*"]}]},
)
StepsSuch requestsFirst, the models that are selected for selection.
SimpleHello, classification, brief translations.GPT-6 Luna
EverydaySummary: Email, small functionsClaude Haiku 5.5
AdvancedFinding bugs, various stages of analysisClaude Sonnet 5.5
ExpertSystem design, verificationClaude 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. tier represents the level of difficulty (1 – simple, 2 – average, 3 – difficult, 4 – professional). judged_tier shows the result of the difficulty assessment. classifier shows the model and token scores used in the evaluation. methods indicates the method used. The tools used are text and tool. If we need to estimate the usage, then usage_estimated will be enabled.
  • mode can be classified as tier if it’s in a step-by-step mode, floor if it’s in a saving mode, and balanced if it’s in a balanced mode. If a decision is skipped or fails, then reason is the reason for that. attempts represents the number of times the question has been asked, while fallbacks represents 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 /responses stream, it can be found in the response.router of 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 that mode is equivalent to floor, and the name of the rule applied to rule is 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_effort with the values that correspond to that value.
  • In the response of router, mode is written as balanced.

Changing the way of selection

OptionsWhat they do
allowed_modelsYou can only select from this model. You can use asterisks, just like in “anthropic/”.
excluded_modelsThis model isn’t uniform.
short_requestsWhen set to “floor”, short requests are sent in a compressed mode. Initially, it’s turned off.
cost_tierIf 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, or response_format available, 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.