This document introduces the OpenAPI of intelligent routing services, including querying route model versions and creating, listing, querying details, editing routing configurations, and deleting intelligent routing services.
Prerequisites
- Read Intelligent Routing to understand concepts such as route model versions, routing strategies, and candidate models.
- A Bailian API key is configured. For more information, see Obtain an API key.
- The request domain varies by region: the Beijing region uses
dashscope.aliyuncs.com, and the Singapore region usesdashscope-intl.aliyuncs.com; the workspace-specific domain ({WorkspaceId}.{region}.maas.aliyuncs.com) is available in all regions. For the complete domain information of each region, see Regions and service deployment scopes.
API Overview
Intelligent routing services reuse the model deployment /api/v1/deployments series of APIs, and use plan="mr" in requests to distinguish the deployment type:
| 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} |
Get a List of Model Routing Versions
Before creating or editing an intelligent routing service, call this API to query the available route model versions, and the strategies and candidate models supported by each version. No request body is required, and plan is not passed.
Request Example
Request Parameters
Parameter | Type | Passing Parameters | Required | Description |
|---|---|---|---|---|
page_no | Number | query | No | Page number. Default is 1. Must be greater than 0. |
page_size | Number | query | No | Page size. Default is 50. Range is 1-1000. |
Response Example and Parameters
Click to view the details.
Click to view the details.
Parameter | Type | Description |
|---|---|---|
total | Long | Total number of selectable routing versions. |
total_page | Number | Total number of pages. |
page_no | Number | Current page number. |
page_size | Number | Current page size. |
route_model_versions | Array | List of routing versions on the current page. |
route_model_versions[].route_model_version | String | Routing version identifier, submitted when you create or edit a deployment. |
route_model_versions[].supported_strategies | Array | Strategies supported by this version: |
route_model_versions[].supported_candidate_model_ids | Array | Set of candidate model IDs supported by this version and not offline. |
route_model_versions[].offline_model_ids | Array | Set of model IDs already offline in this version. It is an empty array when no models are offline. |
- This API does not return inference permission information about candidate models: the appearance of a model in
supported_candidate_model_idsdoes not indicate that the current workspace has been granted invocation authorization for the model. Models without permission are filtered out in real time by the routing service during invocation. - The server filters selectable versions before paginating. If the queried page number exceeds the total number of pages, an empty
route_model_versionsis returned and the total is retained. Paginate bytotal_pageto obtain all results.
Create an Intelligent Routing Service
routing_config is required, and its values are obtained by calling the Get a List of Model Routing Versions API). Do not pass model_name:
Request Example
Request Parameters
Parameter | Type | Passing Parameters | Required | Description |
|---|---|---|---|---|
name | String | body | Yes | Service name: 1-64 characters, only letters, digits, and hyphens are allowed. |
plan | String | body | Yes | Deployment plan. Set this parameter to |
charge_type | String | body | No | Billing method. Intelligent routing supports only |
routing_config | Object | body | Yes | Intelligent routing configuration, which contains the following fields. |
routing_config.route_model_version | String | body | Yes | Route model version, which is obtained by calling the Get a List of Model Routing Versions API. |
routing_config.strategy | String | body | Yes | Routing strategy: |
routing_config.candidate_model_ids | Array | body | Yes | List of candidate model IDs, with at least 1 ID. The IDs must be within the supported range of the selected route model version. Duplicate values are merged, and the order has no routing significance. |
plan is mr, do not pass model_name. Parameters such as suffix, display_name, deploy_spec, SKU, templates, capacity, rate limits, and thinking/context are also not supported. Candidate models that are offline or whose metadata is unavailable cannot be submitted.Response Example and Parameters
After the creation succeeds, the deployment is immediately in the RUNNING status. deployed_model is the deployment instance ID (in the format of auto-model-Ab12Cd34), and the client uses this deployed_model as the model parameter to make calls. model_name is a fixed value auto-model and does not represent the route model version:
Parameter | Type | Description |
|---|---|---|
request_id | String | ID of this request. |
name | String | Service name. |
deployed_model | String | Deployment instance ID (the |
model_name | String | Fixed value |
status | String | Deployment status: |
workspace_id | String | ID of the workspace to which the deployment belongs. |
charge_type | String | Fixed to |
plan | String | Fixed to |
creator | String | UID of the creator. |
modifier | String | UID of the account that performed the last operation. |
gmt_create | String | Creation time. |
gmt_modified | String | Last modification time. |
routing_config | Object | Current routing configuration. The fields are the same as the request parameters. |
List Intelligent Routing Services
Request Example
Pass plan=mr to query only intelligent routing services. If this parameter is omitted, a mixed list of regular deployments and intelligent routing services is returned, and total and pagination count only the matched records:
Request Parameters
Parameter | Type | Passing Parameters | Required | Description |
|---|---|---|---|---|
page_no | Number | query | No | Page number. Default is 1. |
page_size | Number | query | No | Page size. Default is 10. Range is 1-100. |
plan | String | query | No | Pass |
Response Example and Parameters
The fields of each element in the deployments array are the same as the response parameters of creating an intelligent routing service.
Query Intelligent Routing Service Details
Request Example
Request Parameters
Parameter | Type | Passing Parameters | Required | Description |
|---|---|---|---|---|
deployed_model | String | path | Yes | Deployment instance ID, which can be obtained by creating an intelligent routing service or listing intelligent routing services. |
Response Example and Parameters
The response parameters are the same as those of creating an intelligent routing service. Additionally, offline_model_ids (the set of offline model IDs of the current routing version, which is returned only by the detail API) is returned in routing_config:
Edit the Routing Configuration
RUNNING; other statuses return an OperationDenied error. The three routing_config fields are required, and the update is a full replacement rather than a partial update. When you switch route_model_version, the version and its routing are atomically switched by the server: after a successful save, both detail queries and online inference use the new version; if the save fails, the original configuration remains entirely unchanged.Request Example
Request Parameters
Parameter | Type | Passing Parameters | Required | Description |
|---|---|---|---|---|
deployed_model | String | path | Yes | Deployment instance ID. |
routing_config | Object | body | Yes | The routing configuration after full replacement. The fields are the same as those for creating an intelligent routing service: |
Response Example and Parameters
The response is the updated deployment details, and the parameters are the same as those of querying intelligent routing service details.
Delete an Intelligent Routing Service
RUNNING status (the status in the delete response is DELETED). After the deletion, the list and detail queries no longer return the resource, and the deployed_model is not reused. You must create the service again.
Request Example
Request Parameters
Parameter | Type | Passing Parameters | Required | Description |
|---|---|---|---|---|
deployed_model | String | path | Yes | Deployment instance ID. |
Response Example and Parameters
The response is the deployment details before the deletion (status is DELETED), and the parameters are the same as those of querying intelligent routing service details.
Error Responses
Response Parameters
Parameter | Type | Description |
|---|---|---|
request_id | String | System-generated ID of this request. |
code | String | Error code, which indicates the error type. |
message | String | Error details for troubleshooting. Do not rely on the text for business branching. |
Common Errors
Error code | Scenario |
|---|---|
InvalidParameter | Parameter error, such as a missing required field, an empty candidate list or candidate models that do not belong to the selected version, or an invalid service name. |
AccessDenied | No permission or no valid user identity. |
NotFound | The specified deployment does not exist. |
Conflict | Duplicate service name or concurrent conflict. |
QuotaLimit | Quota limit. |
OperationDenied | Operation not allowed in the current status, such as editing the routing configuration when the service is not in the RUNNING status. |
UnsupportedOperation | Unsupported operation, such as compute-related operations like scaling, start/stop, and rate limit configuration. |
InternalError | Internal error. |
ResponseTimeout | Response timeout. |