Wan is an open source AI video generation Large Language Model (LLM) that supports text-to-video (T2V) and image-to-video (I2V). Deploy a ComfyUI service and use Wan to generate video content.
Deploy the Standard Edition of ComfyUI (for single-user use)
Deployment configuration
Deploy the Standard Edition of the ComfyUI image service using a custom deployment method. The procedure is as follows:
Log on to the PAI console. Select a region on the top of the page. Then, select the desired workspace and click Elastic Algorithm Service (EAS).
-
Click Deploy Service. In the Custom Model Deployment section, click Custom Deployment.
On the Custom Deployment page, configure the following parameters.
In the Environment Information area, configure the following parameters.
Parameter
Description
Image Configuration
In the Official Images list, select comfyui and choose the latest available version (for example, comfyui:2.3). Because versions are updated frequently, select the latest version displayed in the console during deployment.
Storage Mount
Mount external storage, such as OSS or NAS, to the EAS service. The generated videos are automatically saved to this storage. Take OSS as an example. Click OSS and configure the following parameters:
Uri: Select the source directory of the OSS Bucket. For information about how to create a bucket and a folder, see Quick Start. Make sure that the created bucket is in the same region as the EAS service.
Mount Path: The destination path to which the storage is mounted in the service instance. For example,
/code/data-oss.
Command
After you select the image, the system automatically configures the run command.
After you configure the storage mount, set the
--data-dirparameter in the Run Command field. The value must be the same as the mount path.The
--data-dirparameter is pre-configured in the image. Simply update it to the mount path in the model configuration. For example,python main.py --listen --port 8000 --data-dir /code/data-oss.In the Resource Information area, select a resource specification.
Parameter
Description
Resource Type
Select Public Resources.
Deployment
Select Resource Specification. Video generation requires large GPU memory. We recommend that you select a resource specification with at least 48 GB of memory for a single GPU. The GU60 instance type is recommended (for example,
ml.gu8is.c16m128.1-gu60).In the Network Information area, configure a virtual private cloud (VPC) that has public network access. For more information, see Access public or private network resources from EAS.
NoteBy default, EAS services cannot access the internet. Because the I2V (image-to-video) feature needs to connect to the internet to download images, you must configure a VPC with public network access for the EAS service.
After you complete the parameter settings, click Deploy.
Use the WebUI
After the service is deployed, build a workflow and generate a video on the WebUI page. The procedure is as follows:
Click the target service name to go to the Overview page, and then click Web applications in the upper-right corner.
In the upper-left corner of the WebUI page, choose Workflow > Open, select the JSON workflow file, and then click Open.
PAI has integrated various acceleration algorithms into ComfyUI. The following are examples of ComfyUI JSON workflows that offer good speed and performance:
Image to Video (upload an image directly): wanvideo_720P_I2V.json
After the workflow is loaded, go to the Load Image area of the WebUI page and click Select file to upload to manually upload and update the image file.
After importing the
wanvideo_720P_I2V.jsonworkflow, the canvas contains the following key nodes:CLIP Vision Loader: Set CLIP name to
wanx_clip_vision_h.safetensorsLoad Image: Click the Select file to upload button to upload the source image
Image Resize (KJ): Width 1280, Height 720, upscale method lanczos
WanVideo ClipVision Encode: strength_1 = 1.000, strength_2 = 1.000, crop = center, combine_embeds = average, tiles = 4, ratio = 0.20
Image to Video (load an image from a URL): wanvideo_720P_I2V_URL.json
After the workflow is loaded, go to the Load Image By URL area of the WebUI page and configure the image URL to update the loaded image.
The workflow contains the following nodes and connections:
CLIP Vision Loader: Set CLIP name to
wanx_clip_vision_h.safetensors, output connected to the clip_vision input of the encode node.Load Image By URL: Load a reference image by URL, cache set to true.
Image Resize (KJ): Width 1280, Height 720, upscale method lanczos, divisible by 16, output connected to the image_1 input of the encode node.
WanVideo ClipVision Encode: strength_1 and strength_2 are both 1.000, crop is center, combine_embeds is average, tiles is 4, ratio is 0.20, outputs image_embeds.
Click the Run button at the bottom of the page to generate the video.
The process takes about 20 minutes. The result is displayed in the Combine into Video area on the right.
After video generation is complete, you can view the output configuration and preview in the Combine into Video node (WanVideoWrapper → VideoHelperSuite). Key output parameters include:
Frame rate: 16
Filename prefix:
WanVideoWrapper_I2VFormat:
video/h264-mp4Pixel format:
yuv420pCRF: 19
Save metadata: true
Synchronous API calls
The Standard Edition service supports only synchronous calls. This means requests are sent directly to the inference instance without using the EAS queue service. The procedure is as follows:
Export the workflow JSON file.
The API request body for ComfyUI depends on the workflow configuration. First, set up the workflow on the WebUI page of the deployed Standard Edition service. Then, in the upper-left corner of the WebUI page, choose Workflow > Export (API) and save the API format to get the corresponding JSON file for the workflow.
View endpoint information.
In the service list, click the service name. In the Basic Information area, click View Endpoint Information.
In the Invocation Information dialog box, obtain the endpoint and token.
NoteTo use the Internet endpoint, the client must be able to access the public network.
To use the VPC endpoint, the client must be in the same VPC as the service.
Select the Shared Gateway or VPC Direct Connection tab to view the corresponding call information.
Call the service.
The following code provides a complete example of how to call the service and obtain the result. In the final result, you can retrieve the full OSS path of the output image from
data[prompt_id]["outputs"]["fullpath"].The sample code retrieves the EAS service endpoint and token from environment variables. You can run the following command in the terminal to add temporary environment variables that are valid only for the current session:
# Set them to the service endpoint and token, respectively. export SERVICE_URL="http://test****.115770327099****.cn-beijing.pai-eas.aliyuncs.com/" export TOKEN="MzJlMDNjMmU3YzQ0ZDJ*****************TMxZA=="
Deploy the API edition of ComfyUI (for high-concurrency scenarios)
Deployment configuration
If you have already created a Standard Edition ComfyUI service and want to change it to the API edition, we recommend that you delete the original service and create a new API edition service.
Deploy the API edition of the ComfyUI image service using a custom deployment method. The procedure is as follows:
Log on to the PAI console. Select a region on the top of the page. Then, select the desired workspace and click Elastic Algorithm Service (EAS).
-
Click Deploy Service. In the Custom Model Deployment section, click Custom Deployment.
On the Custom Deployment page, configure the following parameters.
In the Environment Information area, configure the following parameters.
Parameter
Description
Image Configuration
In the Official Images list, select comfyui and choose the latest available API edition version (for example, comfyui:2.3-api). Because versions are updated frequently, select the latest version displayed in the console during deployment.
Storage Mount
Mount external storage, such as OSS or NAS, to the EAS service. The generated videos are automatically saved to this storage. Take OSS as an example. Click OSS and configure the following parameters:
Uri: Select the source directory of the OSS Bucket. For information about how to create a bucket and a folder, see Quick Start. Make sure that the created bucket is in the same region as the EAS service.
Mount Path: The destination path to which the storage is mounted in the service instance. For example,
/code/data-oss.
Command to Run
After you select the image, the system automatically configures the run command.
After you configure the storage mount, set the
--data-dirparameter in the Run Command field. The value must be the same as the mount path.The
--data-dirparameter is pre-configured in the image. Simply update it to the mount path in the model configuration. For example,python main.py --listen --port 8000 --api --data-dir /code/data-oss.In the Resource Information area, select a resource specification.
Parameter
Description
Resource Type
Select Public Resources.
Deployment
Select Resource Specification. Video generation requires large GPU memory. We recommend that you select a resource specification with at least 48 GB of memory for a single GPU. The GU60 instance type is recommended (for example,
ml.gu8is.c16m128.1-gu60).In the Asynchronous Queue area, configure Maximum Data for A Single Input Request and Maximum Data for A Single Output. The standard value is 1024 KB.
NoteSet the queue data size reasonably to avoid issues such as request rejection, sample loss, response failure, or queue blockage due to size limits.
In the Network Information area, configure a virtual private cloud (VPC) that has public network access. For more information, see Access public or private network resources from EAS.
NoteBy default, EAS services cannot access the internet. Because the I2V (image-to-video) feature needs to connect to the internet to download images, you must configure a VPC with public network access for the EAS service.
After you complete the parameter settings, click Deploy.
Asynchronous API calls
The API edition supports only asynchronous calls and only the api_prompt path. Asynchronous calls send requests through the EAS queue service, and results are obtained through a subscription model. The procedure is as follows:
On the Inference Service tab, click the target service name to go to the Overview page. In the Basic Information section, click View Endpoint Information. In the Invocation Information dialog box, switch to the Asynchronous Invocation tab to view the service access URL and Token.
NoteTo use the Internet endpoint, the client must be able to access the public network.
To use the VPC endpoint, the client must be in the same VPC as the service.
Run the command in the terminal to install the eas_prediction software development kit (SDK).
pip install eas_prediction --userCall the service.
The following code provides a complete example of how to call the service. In the final result, you can retrieve the full OSS path of the output image from
json.loads(x.data.decode('utf-8'))[1]["data"]["output"]["gifs"][0]["fullpath"].The sample code retrieves the EAS service endpoint and token from environment variables. You can run the following command in the terminal to add temporary environment variables that are valid only for the current session:
# Set them to the service endpoint and token, respectively. export SERVICE_URL="http://test****.115770327099****.cn-beijing.pai-eas.aliyuncs.com/" export TOKEN="MzJlMDNjMmU3YzQ0ZDJ*****************TMxZA=="
Appendix: More examples
The usage flow for T2V (text-to-video) and I2V (image-to-video) is the same. Deploy and call the service by following the steps described above. However, T2V does not require an internet connection, so you do not need to configure a VPC when deploying the EAS service.
You can use the sample workflow file (wanvideo_720P_T2V.json) to try the WebUI call flow. For more information, see Use the WebUI. Load the workflow on the WebUI page, enter a text prompt in the WanVideo TextEncode input box, and click Run to start the process.
To call the service through an API, the following is a complete code example:
The sample code retrieves the EAS service endpoint and token from environment variables. You can run the following command in the terminal to add temporary environment variables that are valid only for the current session:
# Set them to the service endpoint and token, respectively.
export SERVICE_URL="http://test****.115770327099****.cn-beijing.pai-eas.aliyuncs.com/"
export TOKEN="MzJlMDNjMmU3YzQ0ZDJ*****************TMxZA=="Synchronous API calls
Asynchronous API calls
References
For a complete guide to deploying ComfyUI, including custom models, plugin installation, and FAQs, see AI video generation - ComfyUI deployment.