Intelligent Routing
Intelligent Routing dynamically analyzes request content and automatically matches the most suitable model from the candidate set, helping enterprises achieve optimal AI resource allocation in complex scenarios.
Overview
The model-code of Intelligent Routing is fixed to the auto-model prefix followed by 8 random characters (e.g., auto-model-abcd1234). The client sends a request with this model-code → the routing service dynamically analyzes the request content and automatically matches the most suitable model from the candidate set → actual model inference → the response is returned (the response body indicates the model that actually executed the request, preserving the real token usage).
Applicable scope:
| Dimension | Description |
|---|---|
| Region | Beijing (cn-beijing) + Singapore (ap-southeast-1) |
| Model type | Text input only |
| Calling protocol | Supports OpenAI-compatible interfaces (Chat Completions, Responses) and the Anthropic protocol (Messages); the DashScope native protocol is not supported |
| Access domain | Only maas.aliyuncs.com is supported (OpenAI-compatible and Responses protocols: https://{WorkspaceId}.{region}.maas.aliyuncs.com/compatible-mode/v1; Anthropic protocol: https://{WorkspaceId}.{region}.maas.aliyuncs.com/apps/anthropic; region is cn-beijing or ap-southeast-1); dashscope.aliyuncs.com (including compatible-mode) is not supported |
| Billing | Pay-as-you-go billing method |
| Rate limiting | Rate limits are applied at the account and workspace levels based on the actually routed model |
Key advantages:
- Maximize model performance: Automatically matches the optimal model for different tasks, especially suited to users with extreme performance requirements.
- Precisely reduce costs: Automatically routes simple tasks to lightweight models and matches complex tasks with advanced models, avoiding the resource waste of using overly powerful models for simple tasks, and achieving a precise match between cost and requirements.
- Eliminate model selection difficulty: No need for users to manually conduct complex model evaluation and comparison; the platform automatically selects the optimal solution throughout, greatly lowering the barrier to model selection.
- Minimal learning curve: Identical to the regular model onboarding process; invoke via model-code without any extra code changes.
Create Intelligent Routing
In the Bailian console, under "Model Inference > Intelligent Routing", click "Create Intelligent Routing" to enter the creation page.
Prerequisites
- A Bailian workspace has been activated.
- The target routing model version has been released, and the current account has been granted invocation permissions for that version and the candidate models.
Procedure
- Enter a service name (required, up to 50 characters).
- Select a released version (maintained by the platform) from the routing model version dropdown.
- Select "Performance first" or "Cost first" as the routing strategy.
- In the model candidate set, select the candidate models (at least 2).
- Click Confirm Deployment to complete the creation.
After successful deployment, the system generates a globally unique model-code (in the form auto-model-XXXXXXXX), and the client invokes it with this model-code. A deleted model-code is never reused.
Besides the console, you can also create Intelligent Routing via OpenAPI. For interface details, see Intelligent Routing API reference.
Routing strategy
The routing strategy determines which model in the candidate set processes each request. Both strategies dynamically match based on request content (not fixed routing) and are selected at creation time.
Strategy | Model selection mechanism | Applicable Scenario |
|---|---|---|
Performance first (EFFECT_FIRST) | Selects the most capable model in the candidate set for each request | Scenarios with strict quality requirements, such as mission-critical business, complex reasoning, and high-quality content generation |
Cost first (COST_FIRST) | Intelligently schedules lightweight models while meeting the performance baseline | Cost-sensitive, high-concurrency scenarios that focus more on latency and unit cost |
Candidate model configuration
The candidate model set is the range from which the routing service can select models. When creating Intelligent Routing, in the "model candidate set" area, select the models to participate in routing from the candidate list. Select at least 2 candidate models, otherwise deployment fails.
NoteRAM users can only select candidate models for which they have been granted
model invocation permissions — if fewer than 2 selectable options are available, you must first grant the RAM user additional model invocation permissions in the workspace.A routing model version is the standardized release form of the Intelligent Routing capability; each version specifies the model range and core capabilities supported by the routing system at the corresponding stage. The candidate model list is determined by the selected routing model version — each version corresponds to one candidate set, and versions cannot be mixed. The currently released routing model versions and their candidate models are as follows:
model-router-20260908
Candidate models | Input | Cache input | Output |
|---|---|---|---|
| CNY 0.8 | CNY 0.1 | CNY 2.7 |
| CNY 20 | CNY 2 | CNY 100 |
| 0-256K: CNY 2 256k-1M: CNY 6 | 0-256K: CNY 0.4 256k-1M: CNY 1.2 | 0-256K: CNY 8 256k-1M: CNY 24 |
| CNY 3 | CNY 0.3 | CNY 9 |
| CNY 1.5 | CNY 0.15 | CNY 4.5 |
| CNY 12 | CNY 2.4 | CNY 36 |
| CNY 8 | CNY 2 | CNY 28 |
| CNY 9 | CNY 0.9 | CNY 27 |
| CNY 4.5 | CNY 0.45 | CNY 13.5 |
| CNY 12 | CNY 1.5 | CNY 36 |
| 0-32K: CNY 0.2 256k-1M: CNY 1.2 32k-256K: CNY 0.6 | 0-32K: CNY 0.04 256k-1M: CNY 0.24 32k-256K: CNY 0.12 | 0-32K: CNY 0.8 256k-1M: CNY 4.8 32k-256K: CNY 2.4 |
The table above shows the invocation prices of each candidate model (CNY per million tokens). The deepseek-v4 series uses peak/off-peak time-based billing. All candidate models support the thinking mode, and thinking tokens are billed at the output price.
NoteWhen selecting candidate models, pay attention to the quota limits of each candidate model to avoid being throttled after being routed to a candidate model due to insufficient quota. We recommend selecting models with sufficient quotas as candidates, or increasing the RPM/TPM quota of the corresponding models for your account before creation.
Invoke Intelligent Routing
After an Intelligent Routing is created, invoking it works the same way as invoking a regular model—simply replace the model parameter in the request with the model-code of the Intelligent Routing (such as auto-model-abcd1234), enabling zero-code-change integration on the client side. Three invocation methods are supported: the OpenAI-compatible interface (Chat Completions and Responses) and the Anthropic protocol. Invocation examples are displayed in tabs by calling protocol.
OpenAI compatible (Chat Completions)
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto-model-abcd1234",
"messages": [{"role": "user", "content": "你好"}]
}'
# OpenAI SDK
from openai import OpenAI
client = OpenAI(
api_key="YOUR_DASHSCOPE_API_KEY",
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
resp = client.chat.completions.create(
model="auto-model-abcd1234",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
print(resp.model) # 实际执行的模型名
# DashScope SDK(需先安装 pip install dashscope)
# 智能路由仅支持 maas.aliyuncs.com 域名,需在构造 Client 时传入业务空间(workspace)与地域(region)
import dashscope
# 智能路由仅支持 maas.aliyuncs.com 域名,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的region取值不同
client = dashscope.Client(
api_key="YOUR_DASHSCOPE_API_KEY",
workspace="{WorkspaceId}",
region="cn-beijing",
)
resp = client.chat.completions.create(
model="auto-model-abcd1234",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
// OpenAI SDK
使用 OpenAI SDK(需先安装 npm install openai)
const OpenAI = require("openai");
const client = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
});
const resp = await client.chat.completions.create({
model: "auto-model-abcd1234",
messages: [{ role: "user", content: "你好" }],
});
console.log(resp.choices[0].message.content);
console.log(resp.model); // 实际执行的模型名
OpenAI compatible (Responses)
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/responses \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto-model-abcd1234",
"input": "你好"
}'
# OpenAI SDK
from openai import OpenAI
client = OpenAI(
api_key="YOUR_DASHSCOPE_API_KEY",
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
resp = client.responses.create(
model="auto-model-abcd1234",
input="你好",
)
# output 为消息块列表,逐块取文本
for item in resp.output:
if item.type == "message":
for block in item.content:
print(block.text)
print(resp.model) # 实际执行的模型名
Anthropic protocol
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic/v1/messages \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto-model-abcd1234",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "你好"}]
}'
# Anthropic SDK(需先安装 pip install anthropic)
# base_url 指向百炼 Anthropic 兼容端点,调用时请将{WorkspaceId}替换为真实的业务空间ID
from anthropic import Anthropic
client = Anthropic(
api_key="YOUR_DASHSCOPE_API_KEY",
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic",
)
resp = client.messages.create(
model="auto-model-abcd1234",
max_tokens=1024,
messages=[{"role": "user", "content": "你好"}],
)
# 备选模型开启思考时响应会先返回思考块,此处仅输出文本块
for block in resp.content:
if block.type == "text":
print(block.text)
print(resp.model) # 实际执行的模型名
Response: The model field in the response body is the identifier of the model that actually processed the request, which you can use to verify whether routing took effect; the response body retains the real token usage, and billing follows the model actually routed to.
Billing: Fees are charged based on the model actually routed to; the Intelligent Routing service itself is currently free of charge.
Automatic failover
Intelligent Routing has built-in automatic failover, enabled by default with no configuration required. When the target model is unavailable, the routing service re-initiates the entire request with another model in the candidate set instead of switching mid-inference.
Automatic failover is not triggered in the following cases, and the error directly surfaces the original information from the actual model:
- 429 (rate limiting)
- Deterministic errors such as 400/403/404/500 (switching models will most likely fail as well)
- Timeouts or network exceptions
- Errors occurring after streaming has started returning content
NoteAutomatic failover does not bill twice: model A → automatic failover → model B succeeds, only the fee of model B is charged.
Real-time filtering rules
The routing service applies real-time filtering to the candidate set:
- Filters out models that the current account has no permission to invoke.
- Filters out models that have been taken offline.
- Filters out models incompatible with the current request parameters (for example, if the request carries
response_format, it only routes to candidate models that support this parameter).
The subset actually available to a single request changes dynamically based on permissions, model status, and request parameters.
Limits
| Limit | Description |
|---|---|
| Calling protocol | OpenAI-compatible interfaces (Chat Completions, Responses) and the Anthropic protocol (Messages); the DashScope native protocol is not supported |
| Request type | Only text input is supported (available via all three interfaces: Chat Completions, Responses, and Messages); image or video input, image generation (text-to-image), Batch batch inference, and non-generative interfaces such as Embedding/Rerank are not supported |
| Context length | The upper limit equals the minimum context window among the models in the candidate set; requests that exceed it fail immediately with an error, without triggering automatic failover |
| Rate limiting | RPM/TPM limits are enforced at the account and workspace level based on the model actually routed to; during automatic failover, only the consumption of the model that ultimately succeeded is counted |
Metric description
Intelligent Routing filters the candidate set in real time based on request parameters and rejects unsupported parameters (returning a 400 error in the form of does not support parameter(s): <parameter name>). The three calling protocols differ in parameter support, as described below:
OpenAI compatible (Chat Completions)
response_format: Routes only to candidate models that support this parameter.enable_search: Routes only to candidate models that support this parameter.reasoning_effort: By default, routes only to candidate models that support this parameter; this parameter supports only thenone,minimal,low,medium,high,xhigh,maxenumeration values.enable_thinking: Set tofalseto disable thinking, which favors non-thinking models; set totrueto automatically exclude non-thinking models and automatically enable thinking.max_tokens: When set, it is automatically converted to themax_completion_tokensparameter before being passed to the candidate models; routing selects only candidate models that support themax_completion_tokensparameter.
In Intelligent Routing mode, the following parameters are not supported; setting them causes a runtime error:
| Parameter | Description |
|---|---|
top_logprobs | Limits the number of logprobs returned |
logit_bias | Token bias |
stop | Stop sequence |
tool_choice | Tool selection |
parallel_tool_calls | Parallel tool calls |
logprobs | Whether to return logprobs |
top_p | Nucleus sampling |
temperature | Sampling temperature |
presence_penalty | Presence penalty |
n | Number of generations |
thinking_budget | Thinking budget length |
OpenAI compatible (Responses)
max_output_tokens: Maximum output length.instructions: System instructions.reasoning.effort: Thinking effort control.- Multi-turn conversations pass the history message array via
input.
The following parameters are not supported; setting them causes a runtime error:
| Parameter | Description |
|---|---|
temperature | Sampling temperature |
top_p | Nucleus sampling |
n | Number of generations |
stop | Stop sequence |
tools | Tool definitions |
Anthropic protocol
max_tokens: Maximum output length, required (a 400 error is returned if it is missing).temperature,top_k,system,tools: Available.- Multi-turn conversations pass the history message array via
messages.
The following parameters are not supported; setting them causes a runtime error:
| Parameter | Description |
|---|---|
top_p | Nucleus sampling |
stop_sequences | Stop sequence |
thinking | Thinking control |
Cache
Intelligent Routing does not support explicit cache parameters:
- If a request is configured with explicit cache flags, the system ignores the explicit cache-related parameters.
- Explicit caching is not involved in billing.
Only the implicit caching provided by the actually invoked model is supported: a cache hit is possible only when the request is routed to the same model and the prompt prefix meets that model's caching conditions. Because different requests may be routed to different models, Intelligent Routing does not guarantee a cache hit rate. For details about how caching works and which models support it, see Context cache.
Manage route service
View detail
After the deployment succeeds, click the service name in the Intelligent Routing list to open the details page, where you can view:
- Basic info: service name,
model-code, running status, routing strategy tag. - Route configuration: route model version, routing strategy, candidate set and candidate model list.
- Billing: pay-as-you-go, billed by the actual model's unit price.
- Deploy config: each candidate model's TPM/RPM throttle quota.
Modify route config
Click "Edit" in the Route Configuration area to modify route version, strategy, and candidate models. Switching version changes the candidate set, taking effect within a few minutes without affecting live requests. You can also edit it through the Update a Model Deployment Task API (PUT /api/v1/deployments/{deployed_model}/update); the semantics is full replacement: all three routing_config fields are required.
After selecting a specific version, online routing behavior remains long-term stable; please conduct a thorough evaluation before upgrading to avoid business impact. Current version: model-router-2026-0908. Route versions are not auto-updated.
Delete service
Delete the Intelligent Routing service from the Intelligent Routing list, or call the delete Intelligent Routing service API (DELETE /api/v1/deployments/{deployed_model}) to delete it directly. After deletion, the model-code cannot be reused; you must create it again.
Manage via API
Besides the console, creating, querying details, listing, editing the routing configuration, and deleting intelligent routing services are all supported through OpenAPI (pay-as-you-go billing only). For the complete API details, see Intelligent Routing API Reference. Supported APIs:
| Function | API |
|---|---|
| Get a list of model routing versions | GET /api/v1/deployments/model-routing/versions |
| Create an intelligent routing service | POST /api/v1/deployments |
| List intelligent routing services | GET /api/v1/deployments?plan=mr |
| Query intelligent routing service details | GET /api/v1/deployments/{deployed_model} |
| Edit the routing configuration | PUT /api/v1/deployments/{deployed_model}/update |
| Delete an intelligent routing service | DELETE /api/v1/deployments/{deployed_model} |
Before creating or editing, call the Get a List of Model Routing Versions API to query the available route model versions, strategies, and candidate models. Intelligent routing does not support compute-related operations such as scaling, start/stop, rate limit configuration, or renaming.
Routing effect
This chapter covers routing effect metrics and monitoring. Effect metrics are viewed on the detail page's "Routing effect" tab; call monitoring is viewed on the Model Monitoring page.
Routing metrics
View the following metrics on the detail page's "Routing effect" tab. The displayed metrics are estimates, for reference only; not for billing settlement; actual billing is based on "Cost and Usage":
Metric | Meaning | Anomaly action |
|---|---|---|
Total routing requests | Total requests received (including failover-succeeded) | Investigate upstream throttling/anomalies on spikes |
Routing success rate | Successfully forwarded requests ÷ total requests × 100% | On drop, check candidate model availability |
Actual model cost (estimated) | Full cost estimated at actual model list price (tiered billing: lowest tier; peak-valley: peak price; excludes free quota; deviates from actual billing) | On rise, check routing strategy and candidate set |
Baseline model cost (estimated) | Hypothetical cost if all handled by the baseline model (same estimation methodology) | — |
Savings | Baseline cost − actual cost (positive means routing saved cost) | — |
Billed request count | Successful requests that incur charges | — |
Spend share | Single-model cost ÷ total cost | On anomaly, check candidate-set distribution |
Cost notes
Cost analysis data has approximately a 1-hour delay and is not real-time. The above costs are all estimated by catalog price as full cost, excluding account discounts and free quotas, for reference only to evaluate routing savings. Tiered billing models use the lowest-tier catalog price; peak-valley pricing models use peak prices. Actual billing can be viewed in "Cost and Usage".
Model monitoring
For more granular call monitoring, go to the Model Monitoring page.
It shows model monitoring and logs at the auto-model dimension, not individual monitoring of the actually-routed models.