Skip to main content
Last Updated: January 8, 2026 This guide will take you step by step through the process of creating and deploying a production ready video-generation service on SaladCloud. We will be using the following technologies:
  • ComfyUI - A highly modular user interface and inference engine for diffusion models.
  • ComfyUI API - A RESTful API for ComfyUI.
  • SaladCloud - A platform for deploying containerized GPU-accelerated applications at scale.
  • Docker - A tool for developing, shipping, and running applications in containers.
  • LTX Video - An open-source Apache 2.0 licensed video generation model capable of both text to video, and image to video generation.
  • Typescript - A strongly typed programming language that builds on JavaScript that we can use to write a custom endpoint for our API.
  • wget - A command-line utility for downloading files from the web. Optional, but useful for downloading model weights.
This guide assumes you have a basic understanding of the technologies listed above. If you are new to any of these tools, we recommend you familiarize yourself with them before proceeding. Additionally, you will need a SaladCloud account to deploy your service. It will be helpful, but not strictly necessary to have a GPU available for local development. Any terminal commands in this guide are written for a Unix-like shell, such as bash, and this guide was developed using Ubuntu 22.
Production Tip: For production video generation, we recommend uploading outputs directly to cloud storage (S3, Azure Blob, Hugging Face) rather than returning them as base64 strings in the response. Video files are significantly larger than images and returning them in the response body can cause memory issues. See the ComfyUI API storage backends documentation for configuration options.

Step 1: Set Up Your Development Environment

Before we can start building our video generation API, we need to set up our development environment, and create a repository to store our code. We will be using Typescript to write our API, so we need to install Node.js and Typescript. If you don’t already have Node.js installed, I recommend using nvm to install and manage Node.js versions. You will also need Docker installed on your machine to build and run your API, as well as to deploy it to SaladCloud. First, let’s create a new directory for our project and initialize the git repo:
We’ll also go ahead and download our model weights to this directory. You may instead link the file from a different directory, if you already have it locally, e.g. in your ComfyUI installation (if you have one). Download the model weights and save them to the video-generation-api directory: This can be done with the following commands:
Next, open your code editor in this directory. Create a new file called .gitignore and add the following content:
This will prevent you from checking the model weights themselves into version control, as they are quite large. Later in this guide we’re going to install javascript modules, and we don’t want to check those in either.

Step 2: Create a Docker Image

We’ll use a manifest file to download models at container startup rather than baking them into the Docker image. This keeps the image small and takes advantage of fast model registry downloads. Create a file called manifest.yaml:
manifest.yaml
Create another new file, and name it Dockerfile. This file will contain the instructions for building your Docker image. Add the following content to the file:
This Dockerfile is based on the ComfyUI API image, which is a pre-built docker image that includes ComfyUI, the ComfyUI API and all dependencies. The tag indicates the version of ComfyUI, ComfyUI API, Torch, and CUDA that the image is built with. The devel tag indicates that this image contains the full CUDA toolkit, which is necessary for running the LTX Video model. The manifest file specifies the model weights and custom nodes to install at startup. For now, we’re going to build this docker image, and then run it to develop our workflow in ComfyUI.
Once the build has completed (this may take a while), you can run the image with the following command:
After 5-10 seconds, you should see a log indicating the success of the ComfyUI API server starting up. You can now go to http://localhost:8188 in your browser to access the ComfyUI user interface. You can use this interface to develop and test your video generation workflow.

Step 3: Develop Your Video Generation Workflow

ComfyUI uses a node-based interface to compose and execute workflows. Each node represents a step in the workflow and the links between nodes represent the flow of data and resources between them. This workflow graph can be saved as a JSON file, which can be imported into ComfyUI to recreate the workflow.

Example Workflow

For this example, we will create a workflow that generates a video of a cute fluffy husky puppy walking through the snow. The workflow will use the LTX Video model to generate the video. This video was created with the following workflow:

Importing and Exporting Workflows

You an import the workflow to ComfyUI by saving the above JSON to a file, and then dragging and dropping the file onto the ComfyUI interface. You should see the nodes and links appear in the interface. Click “Queue” to run the workflow. Make any adjustments to the workflow you’d like, and then export the workflow in the API format. This will generate a JSON file that we’re going to use in the next step.

Setting A Warmup Workflow

ComfyUI API offers the ability to run a warmup workflow before the taking on normal traffic. This allows us to pre-Load the models in vram, and avoid the overhead of loading them on the first request. Save your workflow from the previous step to your project directory as a JSON file, and name it workflow.json. Find the parameter for steps, and decrease it to a smaller number, e.g. 10. This will make the warmup workflow run faster. Find the parameter for length, and decrease it to a smaller number, e.g. 17. This will make the warmup workflow run faster. Note this value must be a multiple of 16, plus 1. Add the following lines to your dockerfile:
This will copy the workflow file into the docker image, and set an environment variable that tells the ComfyUI API to run this workflow as a warmup. Rebuild your docker image:
And run it again:
You will see that it runs the warmup workflow as the first action. Once the warmup is complete, the readiness probe at /ready will return a 200 status code, and the ComfyUI API will be ready to accept requests.

Step 4: Create a Custom Endpoint

ComfyUI API allows us to easily add custom endpoints to our API. We can use these endpoints to expose a much simpler interface for video generation, as opposed to the node-based interface in ComfyUI. We will create a custom endpoint that accepts just a few parameters, including prompt, and length in seconds. Create a new directory in your project called workflows, and create a new file within it called video-clip.ts. At the top, add the following imports and type definitions:
ComfyUI API uses Zod for schema validation, so we’re importing that here. We’re also defining a few types that we’ll use later on. Let’s define our request schema in our typescript file. This will be the shape of the request that our endpoint will accept:
You can see Zod is used to define the shape of the request object. We’re defining the prompt, negative prompt, duration in seconds, steps, cfg, seed, width, and height as the parameters that our endpoint will accept. We’re also defining the default values for these parameters, and any constraints on their values. See the Zod documentation for more information on defining schemas. Next, let’s define the function that will generate the workflow based on the request parameters:
You can see we’ve taken the workflow JSON from earlier, and we use the input parameters to customize the workflow. We’re using the prompt and negative prompt as the text inputs, the duration in seconds as the length of the video (multiplied to be the correct number of frames), and the width and height as the dimensions of the video. We’re also using the steps, cfg, and seed parameters to customize the model behavior. Finally, let’s export the workflow and request schema:

The Completed Endpoint

Now, we need to add this to our Dockerfile. Add the following lines to the end of your Dockerfile:
Build and run your docker image again:
You should see the ComfyUI API server start up, and the warmup workflow run. Navigate to http://localhost:3000/docs in your browser to see the Swagger documentation for your API. You should see a new endpoint called /video-clip that accepts the parameters we defined in our custom endpoint. You can use this endpoint to generate video clips from prompts. Here is an example request:
This script sends a request to the /video-clip endpoint with a prompt and negative prompt, and saves the resulting video to a file. You can see this request structure is simpler and more intuitive than the full ComfyUI workflow graph. You will also see that the video takes quite a while to generate. On my laptop RTX 3080Ti, it took almost 15 minutes to generate a 10 second video. While this number is considerably lower on an RTX 4090, it could still easily exceed the 100 second ide request timeout that SaladCloud’s container gateway imposes.

Step 5: Add A Job Queue

To handle long-running requests like this, we can use SaladCloud’s Job Queue. With the job queue, we can submit our prompt, and then either poll for the result, or receive a webhook when the job is complete. Additionally, the job queue will automatically handle retrying failed requests, buffer overflow requests, and includes some basic autoscaling functionality. To use the job queue, we simply need to add the Job Queue worker binary to our Dockerfile:
Next, we need to create a Job Queue with the Job Queue API.

Step 6: Deploy to SaladCloud

Now, it’s time to upload our container image, and deploy it to SaladCloud. First, we need to tag our image with a registry url. For us here at Salad, that looks like this:
Yours will need to be tagged for a registry you have access to. Next, push it up to the container registry:
This may take some time, depending on your network speed. Once it’s done, you can deploy your container to SaladCloud. Because we are using the Job Queue, we need to create a new Container Group with the Public API. This functionality is not available in the portal.
  • We’re going to start with 3 replicas, and set the container image to the one we just pushed.
  • We’re going to use 4 vCPU, 30GB of RAM, and an RTX 4090 GPU.
  • We’re going to set the priority to “High”, although if your usecase is not time-sensitive, you can achieve significant cost savings by reducing the workload priority. Lower priority workloads can be preempted by higher priority workloads.
  • Additionally, we’re going to reserve 1GB of additional storage, for the temporary storage of video files. ComfyUI API cleans up after itself, but it’s good to have a little extra space just in case.
  • We’re going to connect the container group to the job queue we made in the previous step. Configure the job queue for port 3000 (where our API is running), and set the path to /workflow/video-clip, which is the endpoint we created. For this tutorial, we won’t enable autoscaling, but you can learn more about it here.
  • Finally, we will configure the readiness probe to check the /ready endpoint
  • Finally, ensure autostart_policy is set to true so that the container group starts automatically once the image is pulled into our internal cache.
At this point, Salad will pull the container image into our own high-performance container image cache. You will see this as a “preparing” status on the container group page. Once this has completed, SaladCloud will start to download the container image to compatible nodes in the network. This will take some time, as the container image is quite large, and bandwidth can vary significantly between nodes. While this is happening, you can click on the “System Events” tab to see various events related to the deployment, such as allocating an instance, and downloading the image. Eventually, you will see the container group status change to “Running” when at least 1 instance is up and running.

Step 7: Using the API

Now, we’re going to use the SaladCloud JavaScript SDK to create a function that submits a job to the job queue, and polls for the result. First, we need to initialize a javascript project and install the SDK:
Copy the following into a new file called tsconfig.json:
In a new file called example.ts, add the following code:
Here we’ve imported the SDK, and set up some configuration from environment variables. We’re using the assert function to ensure that these variables are set. Finally, we’ve created an authenticated instance of the SDK. Next, let’s define an interface that matches our endpoint’s request schema:
There’s some polling involved, so we’re going to define a sleep function:
Next, we’re going to define a function that submits a job to the job queue, and polls for the result:
Finally, we’re going to call this function with a request object, and save the video to a file:

Completed Example

Running the Example

Customize the request object in example.ts to your liking, and copy the following script into a file run-ts-example.sh, replacing the placeholders with your organization, project, and queue names. Make sure to set the SALAD_API_KEY environment variable. For help finding your API Key, see this guide.
Make the script executable:
Run the script:
On an RTX 4090, this script takes just under 4 minutes to generate a 10 second video and save it to a file. Now that we have everything working, let’s go ahead and commit our work to git.

Next Steps

Now that you have a working video generation service, and the beginnings of a client that can submit jobs to the job queue, you can start to integrate the video generation service into your own applications. You can also start experimenting with autoscaling to handle more requests, and reduce costs during periods of low demand. ComfyUI API also supports sending workflow progress updates to a webhook, which can be useful to provide real-time feedback to users. The SaladCloud Job Queue also supports webhooks, which can be used to notify your application when a job is complete. This may be preferable to polling, depending on the architecture of the rest of your application and the billing model of your hosting provider.

Summary

In this guide, we used ComfyUI to design a video generation workflow using LTX Video. We created a custom endpoint with ComfyUI API that generates video clips from prompts using that workflow. We deployed this endpoint to a GPU cluster with SaladCloud, behind a job queue for resiliency. We used the SaladCloud SDK to submit jobs to the queue, poll for the result of the job, and save the resulting video to a file.