Publish a trained text model as an online API service.
Applicable scope
- Applicable regions: The regions where the model deployment API is available vary by deployment method — Model Unit (MU) and Dedicated Throughput (DTU) are supported in China (Beijing). If the corresponding deployment method is not available in your region, complete model deployment in the Model Studio console of that region.
- Account permissions: If you use an Alibaba Cloud sub-account (RAM user), you must grant the sub-account permissions for model calling, training, and deployment.
- Configure environment variables: You have successfully obtained an API Key and configured it as an environment variable.
- Read the deployment documentation: We recommend that you first read dedicated deployment overview and create model deployment tasks by using APIs to understand how to use model deployment and the basic steps.
Deployed Models
- China (Beijing)
- Singapore
POST https://dashscope.aliyuncs.com/api/v1/deploymentsRequest domains vary by region: the Beijing region usesdashscope.aliyuncs.com, and the Singapore region usesdashscope-intl.aliyuncs.com; the Dedicated Workspace Host ({WorkspaceId}.{region}.maas.aliyuncs.com) is available in all regions. For the complete domain information of each region, see Regional endpoints.
For Windows CMD, replace$DASHSCOPE_API_KEYwith%DASHSCOPE_API_KEY%; for PowerShell, replace it with$env:DASHSCOPE_API_KEY
Request parameters
Request headers
Parameter | Type | Required | Description |
|---|---|---|---|
Content-Type | String | Yes | Fixed value: |
Authorization | String | Yes | API Key authentication, in the format |
Request body
Request body parameters vary depending on the deployment method (plan). The complete request body parameters and deployment examples for each billing method are as follows:- Billed by DTU dedicated computing power
- By Model Unit
- > After you run the following deployment command, the model deployment service starts billing immediately upon successful deployment, even if you have not called the model yet. We recommend that you confirm the billing rules of the service before running the deployment command.
API requests for DTU deployments must use themaas.aliyuncs.comdomain of the workspace where the deployment resides (for example,ws-vxxx.cn-beijing.maas.aliyuncs.com) and the API Key of that workspace;sku_code,template_code, and capacity ranges are queried through the deployable model list API withplan=dtu. For complete parameters and APIs such as scaling, rate limit modification, and model updates, see Model deployment API reference.
Parameter | Type | Required | Description |
|---|---|---|---|
model_name | String | Yes | The name of the model to deploy, corresponding to the model ID in My Models. It can also be obtained from the output of the Create Training Task API. |
plan | String | Yes | The deployment plan, which determines the billing method: |
display_name | String | Yes | Display name of the service, up to 50 characters (other deployment methods use |
suffix | String | No | Deployment identifier suffix, up to 24 characters; the generated full deployment identifier does not exceed 100 characters. Automatically generated if omitted. |
sku_code | String | Yes | The prepaid SKU available for the current model, queried via the deployable model list API with |
template_code | String | Yes | The deployment template matching the model and SKU; obtained from the same query as |
charge_type | String | Yes | Billing method; for DTU, always set to |
dtu_capacity | Object | Yes | The DTU capacity to purchase; you must provide both |
dtu_capacity.input_tpm | Integer | Yes | The purchased input TPM (tokens/min); a non-negative integer with a maximum of 2147483647, and must be an integer multiple of the step obtained from the query. |
dtu_capacity.output_tpm | Integer | Yes | The purchased output TPM (tokens/min); a non-negative integer with a maximum of 2147483647, and must use the same multiple as the input TPM. |
pre_paid_info | Object | Yes | Upfront purchase and auto-renewal settings. Contains the fields: |
Deployment troubleshooting and performance tuning
The max-num-seqs parameter is not configurable
Model Studio model deployment uses either throughput reservation (a separate product; see its API documentation) or By Model Unit billing. Under both billing methods, throughput, concurrency, and generation speed are preset by the platform. Directly adjusting vLLM inference engine parameters such as max-num-seqs is not supported, and this parameter does not exist in the request parameters of this API.
Under the By Model Unit billing method, you can indirectly control throughput by selecting the Model Unit Type (corresponding to the request parameter template_id) and adjusting Deployed Replicas (corresponding to the request parameter capacity).
Deployment templates and resource isolation
The current deployment template only supports single-node deployment (single-node deployment with enhanced general-purpose inference); multi-card instance isolation is not supported. If you need resource isolation, use the By Model Unit billing method, under which the computing resources are dedicated to your business.
Throttling error handling
When concurrent requests exceed the throttling threshold, the API returns HTTP 429, with the error code Throttling.RateQuota and the error message Requests rate limit exceeded, please try again later. Remedies:
- Throughput reservation (a separate product; see its API documentation): adjust
input_tpmandoutput_tpminptu_capacity(corresponding to Input kTPM and Output kTPM in the console), or reduce the request rate. Under this method, you can choose either auto overflow (switching to pay-as-you-go) or reserved capacity only (requests exceeding the capacity directly return429) as the overflow strategy. - By Model Unit: adjust
rpm_limitandtpm_limit, or reduce the request rate.
Context length tuning
Under the By Model Unit billing method, you can configure the Context Window with the request parameter max_context_length, whose value ranges from 1 to 262144 (the actual upper limit depends on the capability of the deployed model). This parameter limits the context size of a single request, thereby limiting the memory usage per request and reducing the risk of OOM.
When processing tasks with a large number of images, set this parameter based on the image size and the number of images per request.
Response parameters
Parameter | Type | Description |
|---|---|---|
request_id | String | The unique identifier of the request. |
output | Object | Task details. |
output.deployed_model | String | The unique identifier of the deployed model. Used to query the model deployment status and invoke the model. |
output.name | String | The display name of the deployment. |
output.model_name | String | The model identifier name. |
output.base_model | String | The base model used. |
output.status | String | Deployment status: |
output.workspace_id | String | The workspace ID that the API Key belongs to. For more information, see Obtain Workspace ID. |
output.charge_type | String | Billing mode: |
output.creator | String | The Alibaba Cloud account ID of the creator. |
output.modifier | String | The Alibaba Cloud account ID of the modifier. |
output.plan | String | The deployment method. |
output.gmt_create | String | The time when the deployment task was created. |
output.gmt_modified | String | The time when the deployment task was updated. |
Returned only for the model unit (mu) deployment method. | ||
output.base_capacity | Number | The minimum number of resource units required to run the base model. |
output.ready_capacity | Number | The number of resource units that are ready and can process requests immediately. |
output.capacity | Number | The number of resource units used by the deployment. |
output.model_unit_spec | String | The model unit specification. |
output.enable_thinking | Boolean | Whether thinking mode is enabled. |
output.max_context_length | Number | The maximum context length limit. |
output.rpm_limit | Number | Requests per minute. |
output.tpm_limit | Number | Token usage per minute. |
Returned only for the provisioned throughput (ptu_v2) deployment method | ||
output.ptu_capacity | Object | Provisioned throughput configuration, including |
Returned only for the DTU (dtu) deployment method | ||
output.dtu_capacity | Object | The purchased input/output TPM capacity, including |
output.pre_paid_info | Object | Upfront payment and auto-renewal information. |
For a complete list of DTU response fields, see Model deployment API reference | ||
Returned when the call fails | ||
code | String | Error code. Returned when the call fails. |
message | String | Description of the error details. Returned when the call fails. |
- The detailed error description. Returned when the invocation fails.
- Error response example
output.deployed_model (the unique identifier of the deployed model) and output.status (the deployment status).