Publish a trained model as an online API service.
Prerequisites
- Supported regions: The model deployment API is currently available only in the China (Beijing) region. If you use other regions, please deploy models through the Model Studio console in that region.
- Account permissions: If you use Alibaba Cloud sub-accounts (RAM users), you need to grant the sub-account model invocation, training, and deployment permissions.
- Configure environment variables: You have successfully obtained an API Key and configured it as an environment variable.
- Prerequisite: Model fine-tuning training has been completed. Please first call the Query Fine-tuning Job API to confirm the job status
status is SUCCEEDED before proceeding with deployment.
Deploy Model
China (Beijing)
POST https://dashscope.aliyuncs.com/api/v1/deployments
For Windows CMD, replace $DASHSCOPE_API_KEY with %DASHSCOPE_API_KEY%. For PowerShell, replace with $env:DASHSCOPE_API_KEY
Request Parameters Headers Content-Type string (Required) Fixed value: application/json Authorization string (Required) API Key authentication, in the format Bearer sk-xxxx. Request Body model_name string (Required) The model ID to deploy (not the base model name, but the model identifier generated after fine-tuning or export). How to obtain:
- Fine-tuned model: Use the value of
output.finetuned_output in the Create a tuning job response, in the format wan2.5-i2v-preview-ft-202511111122-xxxx.
- Exported model: Use the value of
output[].model_name in the Query Exported Model Details response.
capacity integer (Required) The number of deployed model instances. Recommended value: 1. plan string (Required) Deployment method. Recommended value for LoRA efficient fine-tuning: lora. aigc_config object (Required) Prompt configuration. aigc_config properties use_input_prompt boolean (Required) Controls the prompt source when calling the deployed model to generate videos.
false (default): Automatic generation mode. When calling the video generation API, the system ignores the input prompt and uses the templates configured in aigc_config.prompt and aigc_config.lora_prompt_default to automatically generate prompts.
true: Manual input mode. When calling the video generation API, the system directly uses the input prompt, and the above two parameters become ineffective.
prompt string (Required) Preset Prompt template. Only effective when use_input_prompt=false is set. When calling the deployed model to generate videos, the system analyzes the input image, fills the image content into this template, and automatically generates a complete description with effect instructions. Note: This parameter overrides the prompt parameter passed in the video generation API. lora_prompt_default string (Required) Fallback Prompt template. Only effective when use_input_prompt=false is set. When aigc_config.prompt fails to generate, the system uses this parameter as a fallback prompt to generate the video. | Image-to-Video (First Frame)The following example uses the money rain effect. Upload a portrait image, and the system automatically generates a video with the effect. curl --location 'https://dashscope.aliyuncs.com/api/v1/deployments' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model_name": "<replace with model_name>",
"aigc_config": {
"use_input_prompt": false,
"prompt": "根据图像内容提供视频描述,描述必须包含"然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕她(他)。钞票持续落下,同时镜头缓缓拉进,她(他)双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中"。\n输出模板:\n视频开头展示了[主体描述]。[环境描述]。然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕她(他)。钞票持续落下,同时镜头缓缓拉进,她(他)双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中。\n示例:\n视频开头展示了一位年轻女性在海滩上的场景。她的头发湿漉漉的,呈现出深棕色,卷曲且略显凌乱。她的脸上带着灿烂的笑容。背景是波涛汹涌的海浪和远处的山脉。然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕她。钞票持续落下,同时镜头缓缓拉进,她双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中。",
"lora_prompt_default": "然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕主角。钞票持续落下,同时镜头缓缓拉进,主角双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中。"
},
"capacity": 1,
"plan": "lora"
}'
Image-to-Video (First and Last Frames)The following example uses the fashion magazine outfit change effect. Upload first and last frame images, and the system automatically generates a transition video of the outfit change. curl --location 'https://dashscope.aliyuncs.com/api/v1/deployments' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"model_name": "<replace with model_name>",
"aigc_config": {
"use_input_prompt": false,
"prompt": "根据图像内容提供视频描述,描述必须包含"然后她开始了s86b5p变身。"\n输出模板:\n视频开头展示了[主体描述]。[环境描述]。然后她开始了s86b5p变身。\n示例:\n视频开头展示了一位年轻女性在户外的场景。她有着短而卷曲的深棕色头发,面带微笑,显得非常亲切。她穿着一件黑色的Polo衫,上面有彩色的花卉刺绣图案,背景是绿色的植被和远处的山脉。然后她开始了s86b5p变身。",
"lora_prompt_default": "然后她开始了s86b5p变身。"
},
"capacity": 1,
"plan": "lora"
}'
|
Response Parameters request_id string Unique identifier of the request. output object Task details. Properties deployed_model string Unique identifier of the deployed model. Used to query model deployment status and invoke the model. model_name string Model identifier name. status string Deployment status:
PENDING: Deploying.
RUNNING: Running.
FAILED: Deployment failed.
base_model string The base model used. gmt_create string Deployment task creation time. gmt_modified string Deployment task update time. workspace_id string The workspace ID associated with the Alibaba Cloud Model Studio API Key. See Get the Workspace ID. charge_type string Billing mode. post_paid indicates pay-as-you-go. creator string Alibaba Cloud account ID of the creator. modifier string Alibaba Cloud account ID of the modifier. plan string Deployment method. code string Error code. Returned when the call fails. See the error code table below. message string Detailed error description. Returned when the call fails. | Success Response ExampleKey fields: output.deployed_model (unique identifier of the deployed model), output.status (deployment status). {
"request_id": "96020b2e-9072-4c8a-9981-xxxxxxxxx",
"output": {
"deployed_model": "wan2.5-i2v-preview-ft-202511111122-xxxx",
"gmt_create": "2025-11-11T17:46:53.294",
"gmt_modified": "2025-11-11T17:46:53.294",
"status": "PENDING",
"model_name": "wan2.5-i2v-preview-ft-202511111122-xxxx",
"base_model": "wan2.5-i2v-preview",
"workspace_id": "llm-xxxxxxxxx",
"charge_type": "post_paid",
"creator": "12xxxxxxx",
"modifier": "12xxxxxxx",
"plan": "lora"
}
}
Error Response Example{
"code": "InvalidParameter",
"request_id": "BE213CDD-8A5C-59EE-9A67-055EAB0CB59B",
"message": "The model xxx does not exist or is not deployable"
}
|
Prompt Template Configuration
The following explains how to configure the aigc_config.prompt parameter.
-
Why set this parameter?
Without this parameter, you would need to manually write a complete Prompt each time you call the deployed model. Once configured, when calling the fine-tuned model to generate videos, you only need to upload an image, and the system will automatically complete the effect instructions based on this parameter without requiring manual Prompt input.
-
How to configure?
Prompt = Task instruction (tells the model what to do) + Output template (standardizes output format) + Example (helps the model learn the example structure).
根据图像内容提供视频描述,描述必须包含"然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕她(他)。钞票持续落下,同时镜头缓缓拉进,她(他)双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中"。
输出模版:
视频开头展示了[主体描述]。[环境描述]。然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕她(他)。钞票持续落下,同时镜头缓缓拉进,她(他)双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中。
示例:
视频开头展示了一位年轻女性在海滩上的场景。她的头发湿漉漉的,呈现出深棕色,卷曲且略显凌乱。她的脸上带着灿烂的笑容。背景是波涛汹涌的海浪和远处的山脉。然后开始展示s86b5p金钱雨特效,无数巨大尺寸的美元钞票(米黄底/深绿图案)如暴雨般倾泻而下,密集地砸向并环绕她。钞票持续落下,同时镜头缓缓拉进,她双臂舒展上扬,脖颈微仰,表情惊喜,完全沉浸在这场狂野的金钱雨中。
For the "Output template" description, see Video annotation: Write prompts for videos.
Next Step
Deployment is an asynchronous operation. After calling this API, you can query the deployment status through the Query and Manage Deployments API.