Skip to main content
This tutorial shows you how to build a complete text-to-video pipeline by chaining three Runpod Public Endpoints together. You’ll take a simple idea and transform it into an animated video, all with a single Python script.

What you’ll build

The pipeline takes a basic prompt like “a cat wearing sunglasses” and:
  1. Uses Qwen3 32B to enhance the prompt into a detailed image description.
  2. Uses Flux Schnell to generate an image from the enhanced prompt.
  3. Uses WAN 2.5 to animate the image into a 5-second video.

Requirements

Before you begin, you’ll need:

Estimated cost

Public Endpoints pricing is based on actual usage. Here’s an estimated cost for running the pipeline based on the models used: You won’t be charged for failed generations.

Step 1: Set up your project

Create a new directory for your project with a virtual environment and set your API key. Replace YOUR_API_KEY with your actual API key.
Create a new file called pipeline.py and add the following imports and configuration:

Step 2: Enhance the prompt with Qwen3 32B

The first step uses Qwen3 32B to transform a simple idea into a detailed, image-generation-optimized prompt. This significantly improves the quality of the generated image. Add the following function to your script:
This function:
  • Sends the simple prompt to Qwen3 32B using the OpenAI-compatible API
  • Uses a system prompt that instructs the model to act as an image prompt expert
  • Strips any reasoning tags from the output
  • Returns the enhanced, detailed prompt

Step 3: Add a polling helper

Image and video generation can take time, so you’ll use asynchronous requests with polling. Add this helper function:

Step 4: Generate an image with Flux Schnell

Next, use Flux Schnell to generate an image from the enhanced prompt. Flux Schnell is optimized for speed.
This function:
  • Submits an asynchronous job to Flux Schnell
  • Polls until the job completes
  • Uses a 1024x1024 resolution (optimal for video generation)
  • Returns the URL of the generated image

Step 5: Animate the image with WAN 2.5

Now animate the static image into a video using WAN 2.5.
This function:
  • Submits an asynchronous job to WAN 2.5
  • Uses the polling helper with a longer timeout (video generation takes longer)
  • Returns the URL of the generated video

Step 6: Download the output

Add a helper function to download the final video:

Step 7: Put it all together

Add the main function that chains all the steps together:

Full code

Expand the section below to see the full pipeline.py code:

Run the pipeline

Run the script:
The script will output progress as it runs:
Output URLs expire after 7 days. The script downloads files immediately to avoid losing them.

Next steps

Now that you have a working pipeline, you can extend it in several ways:
  • Try different prompts: Experiment with landscapes, characters, or abstract concepts.
  • Adjust video settings: Change the duration or resolution in the WAN 2.5 request.
  • Use different models: Swap Flux Schnell for Flux Dev for higher quality (but slower) generation.
  • Add error handling: Implement retries for transient failures.
  • Build a web interface: Wrap the pipeline in a Flask or FastAPI application.
  • Batch processing: Process multiple prompts in parallel.