
What you’ll build
The pipeline takes a basic prompt like “a cat wearing sunglasses” and:- Uses Qwen3 32B to enhance the prompt into a detailed image description.
- Uses Flux Schnell to generate an image from the enhanced prompt.
- Uses WAN 2.5 to animate the image into a 5-second video.
Requirements
Before you begin, you’ll need:- A Runpod account with at least $1 in credits.
- A Runpod API key.
- Python 3.8 or later installed on your local machine.
Estimated cost
Public Endpoints pricing is based on actual usage. Here’s an estimated cost for running the pipeline based on the models used:| Step | Model | Cost |
|---|---|---|
| Prompt enhancement | Qwen3 32B | ~$0.01 |
| Image generation | Flux Schnell | ~$0.003 |
| Video generation | WAN 2.5 | ~$0.25 |
| Total | ~$0.26 |
Step 1: Set up your project
Create a new directory for your project with a virtual environment and set your API key. ReplaceYOUR_API_KEY with your actual API key.
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:- 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.- 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.- 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 fullpipeline.py code:
pipeline.py code
pipeline.py code
Run the pipeline
Run the script: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.
Related resources
- Public Endpoints overview
- Qwen3 32B reference
- Flux Schnell reference
- WAN 2.5 reference
- Vercel AI SDK for TypeScript projects