Template Components
The ComfyUI Wan 2.2 template includes: In the Docker Image:- ComfyUI
- ComfyUI API Wrapper
- Stable Diffusion 1.5 (for benchmarking)
- PyWorker (comfyui-json worker)
- Provisioning Script for custom configuration
- Adds cron job to remove older output files (older than 24 hours) if available disk space is less than 512MB
- Adds benchmarking workflow file
- Downloads Wan 2.2 models:
text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensorsvae/wan_2.1_vae.safetensorsdiffusion_models/wan2.2_t2v_low_noise_14B_fp8_scaled.safetensorsdiffusion_models/wan2.2_t2v_high_noise_14B_fp8_scaled.safetensorsloras/wan2.2_t2v_lightx2v_4steps_lora_v1.1_high_noise.safetensorsloras/wan2.2_t2v_lightx2v_4steps_lora_v1.1_low_noise.safetensors
Before using this template, familiarize yourself with the Serverless Documentation and Getting Started With Serverless guide. Learn more about Wan 2.2 T2V A14B on Hugging Face.
Environment Variables
Required for S3 Storage
The API wrapper manages asset uploads to S3-compatible storage. Configure these variables in your Account Settings:S3_ACCESS_KEY_ID(string): Access key ID for S3-compatible storageS3_SECRET_ACCESS_KEY(string): Secret access key for S3-compatible storageS3_BUCKET_NAME(string): Bucket name for S3-compatible storageS3_ENDPOINT_URL(string): Endpoint URL for S3-compatible storageS3_REGION(string): Optional region for S3-compatible storage
These S3 values can be overridden on a per-request basis in the request payload.
Optional Configuration
WEBHOOK_URL(string): Optional webhook to call after generation completion or failurePYWORKER_REPO(string): Custom PyWorker git repository URL (default: https://github.com/vast-ai/pyworker)PYWORKER_REF(string): Git reference to checkout from PyWorker repository
Store sensitive information like API keys in the ‘Environment Variables’ section of your Account Settings. These will be available in all instances you create.
Worker Startup Process
When a worker is first started with this template, the following will happen:- Docker image is downloaded if not already cached on the host machine
- Worker (Docker container) is created on the host machine
- Template on-start script is executed:
- Docker image entrypoint is executed
- Download and run provisioning script (remotely stored Bash script)
- Start supervisord (ComfyUI & API wrapper process manager)
- Current version of Vast PyWorker bootstrapping script is downloaded and executed
- ComfyUI and API Wrapper become available
- PyWorker begins benchmarking
- Benchmarking completes and worker score is sent to the serverless system
- Ready (hot): Worker is fully initialized and immediately available to process requests. You pay for idle time.
- Inactive (cold): Worker is shut down to save costs. You pay only for storage.
Benchmarking
A Wan 2.2 video generation benchmark runs when each worker initializes to validate GPU performance and identify underperforming machines. The benchmark file is downloaded on first start and stored in the pyworker directory atworkers/comfyui-json/misc/benchmark.json. The workflow is static but a random seed will be generated for each benchmarking run.
Performance expectations:
- Benchmark duration should remain consistent across identical GPU models
- Significant variation (>20%) may indicate thermal, power, or configuration issues
Understanding Worker Scores
The benchmarking system calculates a performance score for each worker that determines how requests are distributed: How scoring works:- Each benchmark is assigned a baseline complexity score of
100(representing 100% of the work) - If a worker completes the benchmark in 100 seconds, it receives a score of
1.0(it processes 1% of the work per second) - If a worker completes the same benchmark in 50 seconds, it receives a score of
2.0(twice as fast) - If a worker completes the same benchmark in 200 seconds, it receives a score of
0.5(half as fast)
- Faster workers (higher scores) receive more requests proportionally
- To serve 1 request per second on average with score-1.0 workers, you need 100 workers
- With score-2.0 workers, you only need 50 workers for the same throughput
- The system automatically balances load based on these scores
If you choose to use your own worker code, it’s recommended to implement a custom benchmark that closely matches the video generation workflows you intend to process.
Endpoints
The ComfyUI Wan 2.2 template provides endpoints for executing workflows and generating videos. After obtaining a worker address from the/route/ endpoint (see route documentation), you can send requests to the following endpoints.
/generate/sync
The primary endpoint for submitting ComfyUI workflows. This endpoint accepts complete, user-defined ComfyUI workflows in JSON format and processes them synchronously.Request Structure
Input
payload:
input:request_id(string): Optional unique identifier for tracking the requestworkflow_json(object): Complete ComfyUI workflow graph in JSON formats3(object): Optional S3 configuration overrideaccess_key_id(string)secret_access_key(string)endpoint_url(string)bucket_name(string)region(string)
webhook(object): Optional webhook configurationurl(string): Webhook URL to call after generationextra_params(object): Additional parameters to include in webhook payload
The string
"__RANDOM_INT__" in your workflow will be replaced with a random integer prior to posting the workflow to ComfyUI, allowing for varied outputs without manually specifying different seeds.Outputs
id(string): Unique identifier for the requeststatus(string): Request status -completed,failed,processing,generating, orqueuedmessage(string): Human-readable status messagecomfyui_response(object): Detailed response from ComfyUI including:prompt: The workflow that was executedoutputs: Generated outputs organized by node IDstatus: Execution status with completion messages and timestampsmeta: Metadata about the executionexecution_details: Progress updates and timing information with detailed progress_updates array showing generation progress
output(array): Array of output objects, each containing:filename(string): Name of the generated file (e.g., “ComfyUI_00003_.mp4”)local_path(string): Path to file on workerurl(string): Pre-signed URL for downloading the generated video asset (if S3 is configured)type(string): Output type (e.g., “output”)subfolder(string): Subfolder within output directory (e.g., “video”)node_id(string): ComfyUI node that produced this outputoutput_type(string): Type of output (e.g., “images”)
timings(object): Timing information for the request
JSON
Ensure that the Wan 2.2 T2V A14B models and any required custom nodes are already installed before sending a request. This template pre-installs all necessary Wan 2.2 T2V A14B models during first boot.
Testing Before Deployment
Although this template is designed for serverless deployment, you can test it as an interactive instance first. To access ComfyUI and the API wrapper:- Start an interactive instance with this template
- Connect via SSH with port forwarding:
- Access ComfyUI at http://localhost:18188
- Access the API Wrapper documentation at http://localhost:18288/docs
About Wan 2.2 T2V A14B
Wan 2.2 T2V A14B is a text-to-video generation model that creates high-quality video from text prompts. The model uses a two-stage diffusion process with separate high-noise and low-noise models for improved video quality and temporal consistency. Key features:- Text-to-video generation with positive and negative prompts
- Two-stage diffusion process (high-noise and low-noise models)
- Support for LoRA models for faster inference (LightX2V 4-step variants)
- Configurable video dimensions (width, height, length)
- Adjustable frame rate (FPS)
- High-quality MP4 video output
- UMT5-XXL text encoder (FP8 quantized)
- Wan 2.1 VAE for video encoding/decoding
- Dual 14B diffusion models (FP8 quantized) for high-noise and low-noise stages
- Optional LoRA models for accelerated inference