Text Generation - Create Deployment
Deploy a trained text model as an online API service.
Prerequisites
- Supported region: The model deployment API is currently only available in the China (Beijing) region. If you are using a different region, please complete the model deployment through the Model Studio console for that region.
- Account permissions: If using an Alibaba Cloud sub-account (RAM user), you need to grant the sub-account permissions for model invocation, training, and deployment.
- Configure environment variables: You have successfully obtained an API Key and configured it as an environment variable.
- Read deployment documentation: It is recommended to first read Model deployment overview and Create a model deployment using API to understand the usage and basic steps of model deployment.
Create a deployment
China (Beijing)
POST https://dashscope.aliyuncs.com/api/v1/deployments
For Windows CMD, replace
$DASHSCOPE_API_KEYwith%DASHSCOPE_API_KEY%. For PowerShell, replace it with$env:DASHSCOPE_API_KEY
Request parametersHeadersContent-Type Fixed value: Authorization API Key authentication, in the format Request Bodymodel_name The name of the model to deploy, corresponding to the Model ID in My Models. You can also obtain it from the output of the Create a tuning job API. plan Deployment plan. Valid values:
deploy_spec Deployment template. Required when You can obtain it from the capacity The number of resource units for the deployment, which must be an integer multiple of billing_method Billing method. Required when enable_thinking Only configurable when max_context_length Only configurable when rpm_limit Only configurable when tpm_limit Only configurable when ptu_capacity Only takes effect when name The display name of the model in the console. If not provided, the value of suffix After model deployment, a new model name will be generated. The suffix is used to specify the suffix of the new model name, with a maximum length of 8 characters and must be globally unique. When deploying a model for the first time, the suffix can be omitted. For subsequent deployments of the same model, a suffix must be specified to distinguish between them. | Model unit billingBilling is based on the usage duration of model units. Suitable for large-scale inference after model fine-tuning, with dedicated resources and flexible performance and cost control.
Token-based billingBilling is based on token usage. Suitable for cost-effective scenarios with lower concurrency and latency requirements. This mode offers the best pricing, with throughput/concurrency and generation speed preset by the platform and not user-adjustable. Provisioned throughput billingBilling is based on the usage duration of provisioned throughput. Suitable for scenarios requiring stable throughput guarantees with high concurrency and low latency, and predictable traffic. Throughput/concurrency and generation speed are preset by the platform and not user-adjustable.
|
Deployment troubleshooting and performance tuning
max-num-seqs parameter is not configurable
Under both provisioned throughput billing and model unit billing plans, throughput, concurrency, and generation speed are all preset by the platform. Direct adjustment of inference engine parameters such as max-num-seqs in vLLM is not supported, and this parameter does not exist in the request parameters of this API.
Under the model unit billing plan, you can indirectly control throughput by selecting the model unit type (corresponding to the request parameter deploy_spec) and adjusting the number of deployment replicas (corresponding to the request parameter capacity).
Deployment template and resource isolation
Currently, the deployment template only supports single-machine deployment (Single-machine deployment - Enhanced general inference) and does not support multi-GPU instance isolation. For resource isolation, use the model unit billing plan, which provides dedicated computing resources for your workload.
Throttling error handling
When concurrent requests exceed the throttling threshold, the API returns HTTP 429 with error code Throttling.RateQuota and error message Requests rate limit exceeded, please try again later. You can handle this as follows:
- Provisioned throughput billing: Adjust
ptu_capacityvalues forinput_tpmandoutput_tpm(corresponding to Input kTPM and Output kTPM in the console), or reduce the request frequency. Under this plan, the overflow strategy can be set to Auto overflow (switch to pay-as-you-go billing) or Use PTU capacity only (requests exceeding capacity will directly return429). - Model unit billing: Adjust
rpm_limitandtpm_limit, or reduce the request frequency.
Context length tuning
Under the model unit billing plan, you can configure the maximum context length via the request parameter max_context_length, with a value range of 1 to 262144 (the actual upper limit depends on the capabilities of the deployed model). This parameter limits the context size per request, thereby limiting the memory usage per request and reducing the risk of OOM errors.
When processing tasks with a large number of images, set this parameter based on the image dimensions and the number of images per request.
Response parametersrequest_id The unique identifier of the request. output Task details. code Error code. Returned when the call fails. message Detailed error description. Returned when the call fails. | Success response exampleKey fields: Error response example |
Next steps
Deployment is an asynchronous operation. After calling this API, you can use the Get deployment details API to query the deployment status.