Skip to main content

Text Generation - Create Deployment

Deploy a trained text model as an online API service.

Prerequisites

Create a deployment

  • China (Beijing)
POST https://dashscope.aliyuncs.com/api/v1/deployments
For Windows CMD, replace $DASHSCOPE_API_KEY with %DASHSCOPE_API_KEY%. For PowerShell, replace it with $env:DASHSCOPE_API_KEY

Request parameters

Headers
Content-Type string (Required)Fixed value: application/jsonAuthorization string (Required)API Key authentication, in the format Bearer sk-xxxx.
Request Body
model_name string (Required)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 string (Required)Deployment plan. Valid values:
  • mu: Model unit billing.
  • lora: LoRA shared deployment (token-based billing).
  • ptu: Provisioned throughput billing.
deploy_spec string (Conditionally required)Deployment template. Required when plan is mu. Example: "deploy_spec": "MU1".You can obtain it from the template_id field returned by the List deployable models API.capacity integer (Conditionally required)The number of resource units for the deployment, which must be an integer multiple of base_capacity. Different deploy_spec values have different constraints. For example, MU2 must be a multiple of 8, while MU5 can be 1.billing_method string (Conditionally required)Billing method. Required when plan is mu. Currently supports "POST_PAY" (pay-as-you-go).enable_thinking boolean (Optional)Only configurable when plan is mu. Supported by some models. Can be set to true or false.max_context_length number (Optional)Only configurable when plan is mu. Supported by some models. Example: "max_context_length": 131072.rpm_limit number (Optional)Only configurable when plan is mu. Supported by some models. Requests per minute.tpm_limit number (Optional)Only configurable when plan is mu. Supported by some models. Tokens per minute.ptu_capacity object (Optional)Only takes effect when plan is ptu. If not provided, defaults to 10,000 input_tpm and 1,000 output_tpm.

ptu_capacity properties

input_tpm numberThe maximum input tokens per minute supported by the deployed model.output_tpm numberThe maximum output tokens per minute supported by the deployed model.thinking_output_tpm numberSupported by some models. The maximum thinking output tokens per minute supported by the deployed model.
name string (Optional)The display name of the model in the console. If not provided, the value of model_name will be used as the deployment name.suffix string (Optional)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 billing
  • Token-based billing
  • Provisioned throughput billing
Billing 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.
After executing the deployment command below, billing will start once the deployment is successful, even if you have not yet invoked the model. Please confirm the billing rules before executing the deployment command.
curl "https://dashscope.aliyuncs.com/api/v1/deployments" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "name": "my_qwen_plus",
    "model_name": "qwen-plus-2025-12-01",
    "plan": "mu",
    "deploy_spec": "MU1",
    "enable_thinking": true,
    "capacity": 4,
    "billing_method": "POST_PAY",
    "max_context_length": 10000,
    "rpm_limit": 500,
    "tpm_limit": 1000
}'

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_capacity values for input_tpm and output_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 return 429).
  • Model unit billing: Adjust rpm_limit and tpm_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 parameters

request_id stringThe unique identifier of the request.output objectTask details.

Properties

deployed_model stringThe unique identifier of the deployed model. Used to query deployment status and invoke the model.model_name stringThe model identifier name.status stringDeployment status:
  • PENDING: The deployment task is being created.
  • UPDATING: The deployment task is being updated.
  • RUNNING: The deployment task is running. The deployed model can process requests normally.
  • STOPPED: The deployment task has been stopped and will not incur charges.
  • DELETING: The deployment task is being deleted.
  • FAILED: The deployment task creation or update has failed.
base_model stringThe base model used.gmt_create stringThe creation time of the deployment task.gmt_modified stringThe last modification time of the deployment task.workspace_id stringThe workspace ID associated with the Alibaba Cloud Model Studio API Key. See Get the Workspace ID.charge_type stringBilling mode. post_paid indicates pay-as-you-go.creator stringThe Alibaba Cloud account ID of the creator.modifier stringThe Alibaba Cloud account ID of the last modifier.plan stringThe deployment plan.base_capacity numberThe minimum number of resource units required to run the base model.ready_capacity numberThe number of resource units that are ready and can immediately process requests.model_unit_spec stringThe model unit specification. Only returned when plan is mu.enable_thinking booleanWhether thinking mode is enabled. Only returned when plan is mu.max_context_length numberThe maximum context length limit. Only returned when plan is mu.rpm_limit numberRequests per minute. Only returned when plan is mu.tpm_limit numberTokens per minute. Only returned when plan is mu.ptu_capacity objectProvisioned throughput configuration. Only returned when plan is ptu.

ptu_capacity properties

input_tpm numberThe maximum input tokens per minute supported by the deployed model.output_tpm numberThe maximum output tokens per minute supported by the deployed model.thinking_output_tpm numberSupported by some models. The maximum thinking output tokens per minute supported by the deployed model.
code stringError code. Returned when the call fails.message stringDetailed error description. Returned when the call fails.
  • Success response example
  • Error response example
Key fields: output.deployed_model (unique identifier of the deployed model) and output.status (deployment status).
{
    "request_id": "f2ae64f7-83cc-410c-bc0b-840443f7eb86",
    "output": {
        "deployed_model": "qwen-plus-2025-12-01-mu-xxxx",
        "gmt_create": "2025-06-17T11:00:38.68",
        "gmt_modified": "2025-06-17T11:00:38.68",
        "status": "PENDING",
        "model_name": "qwen-plus-2025-12-01",
        "base_model": "qwen-plus",
        "model_unit_spec": "MU1",
        "enable_thinking": true,
        "max_context_length": 10000,
        "rpm_limit": 500,
        "tpm_limit": 1000,
        "base_capacity": 1,
        "ready_capacity": 0,
        "workspace_id": "llm-v71tlv3d***",
        "charge_type": "post_paid",
        "creator": "175805416***",
        "modifier": "175805416***",
        "plan": "mu"
    }
}

Next steps

Deployment is an asynchronous operation. After calling this API, you can use the Get deployment details API to query the deployment status.
Text Generation
Image Generation
Video Generation
World models
3D Model Generation
Audio
  • Audio generation
Realtime API
Text Embedding
Decision Model
TokenPlan
Model Production