Publish a trained model as an online API service.
Prerequisites
- Supported regions: The model deployment API is currently available only in the Singapore 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
statusis SUCCEEDED before proceeding with deployment.
Deploy Model
- Singapore
POST https://dashscope-intl.aliyuncs.com/api/v1/deploymentsFor Windows CMD, replace$DASHSCOPE_API_KEYwith%DASHSCOPE_API_KEY%. For PowerShell, replace with$env:DASHSCOPE_API_KEY
Request ParametersHeadersContent-Typestring (Required)Fixed value: application/jsonAuthorization string (Required)API Key authentication, in the format Bearer sk-xxxx.Request Bodymodel_namestring (Required)The model ID to deploy (not the base model name, but the model identifier generated after fine-tuning or export). How to obtain:
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.
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. |
The following example uses the money rain effect. Upload a portrait image, and the system automatically generates a video with the effect. |
Response Parametersrequest_idstringUnique identifier of the request.output objectTask details.
Properties deployed_model stringUnique identifier of the deployed model. Used to query model deployment status and invoke the model.model_name stringModel identifier name.status stringDeployment status:
stringThe base model used.gmt_create stringDeployment task creation time.gmt_modified stringDeployment task update time.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 stringAlibaba Cloud account ID of the creator.modifier stringAlibaba Cloud account ID of the modifier.plan stringDeployment method.stringError code. Returned when the call fails. See the error code table below.message stringDetailed error description. Returned when the call fails. |
Key fields: output.deployed_model (unique identifier of the deployed model), output.status (deployment status). |
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).
For the "Output template" description, see Video annotation: Write prompts for videos.