Building an Automated Short-Video Generation Pipeline with an AI Agent Workflow
This article explains how to build a fully automated agent workflow for generating educational short videos—using an "animal evolution history" video as an example. It covers architecture design, node-by-node implementation (LLM script generation, visual prompt translation, batch image generation, first/last-frame-controlled video generation, and code-based data aggregation), along with prompt engineering techniques, optimization strategies such as JSON error tolerance and concurrency control, and how this methodology extends to broader automated content production scenarios.
Introduction
With the rapid advancement of large language models (LLMs) and multimodal technologies, traditional content production—relying entirely on manual topic planning, copywriting, and asset matching—can no longer meet the demand for efficient, high-volume output. An agent workflow decomposes complex tasks into multiple logical nodes and combines LLM capabilities with external tools and APIs, forming a fully automated pipeline from input to output. Using the automated production of an “animal evolution history” educational short video as an example, this article walks through how to build a highly available, easily extensible agent workflow on a mainstream LLM orchestration platform.
1. Business Scenario Analysis and Architecture Design
In educational short-video creation, the core requirement is to transform specific biological knowledge (such as the evolutionary history of a particular animal) into visually striking, logically coherent videos. The traditional process—researching materials, writing scripts, visualizing scenes, generating illustrations, animating, and finally editing—is extremely time-consuming.
An agent workflow supports the following automated architecture:
- Input layer: Accepts the user-selected topic (e.g., “the evolution of chickens”) along with platform authentication information.
- Cognitive layer: Uses an LLM for knowledge retrieval and script writing, then converts the output into structured prompts suitable for image and video generation.
- Visual generation layer: Calls multimodal large models to batch-generate static images based on the prompts, then uses those images as keyframes to generate animated video clips.
- Aggregation layer: Uses a code node to clean and format the results, ultimately producing an asset list ready for direct video synthesis.
2. Core Node Breakdown and Prompt Engineering
The heart of any agent workflow lies in defining each node’s capabilities and managing data flow between them. Below are the implementation steps and technical details.
2.1 Start Node: Parameter Definition and Task Initialization
The workflow’s entry point must clearly define its input parameters. The initialization node typically requires two categories of configuration:
- Authentication parameters: e.g., a platform API Key, used by downstream nodes to validate calls to LLM services.
- Business variables: e.g., a
subjectvariable, allowing users to enter text such as “the evolution of pigs” or “the evolution of cattle.” This variable serves as the initial seed and threads through the entire generation logic of the workflow.
2.2 LLM Script Generation Node: Role Play and Structured Output
This node is the “brain” of the workflow, responsible for turning a simple topic into a detailed script. To ensure professional, well-formatted output, apply the “role setting” technique from prompt engineering.
In the system prompt, the LLM is positioned as a “paleo-era sketch writer,” with the specialty of “compressing the evolutionary history of any animal or plant taxon into a dense 9–10 line timeline.”
In the user prompt, dynamically reference the subject variable from the start node and require the model to output strictly in timeline format. This strong constraint ensures the LLM produces structured text rather than free-flowing prose, providing precise contextual grounding for downstream nodes such as image generation.
2.3 Visual Script Prompt Generation Node: Translating Text into Multimodal Instructions
Although the LLM-generated script is logically rigorous, it cannot be directly understood by image or video generation models. A second LLM node is therefore introduced, positioned as a “paleo-ecosystem visual script engineer.”
This node takes the “era + species + timeline” text from the previous step and translates it into instructions that can be fed directly to visual models. The system prompt must require output in two parts:
- Image generation prompts: descriptions covering species features, environmental backdrop, lighting, and style.
- Video generation prompts: descriptions covering camera movement, motion amplitude, and transition effects.
This node is the critical bridge between language models and visual models—the quality of its prompt design directly determines the final visual output.
2.4 Batch Image Generation Node and Generator Integration
Based on the image prompt list from the previous step, the workflow enters batch-processing mode. During this stage, the orchestration platform calls the underlying image generation model via loops or concurrency.
At the node configuration level, a generic plugin or API such as an “image_generator” is typically used. This node takes the batch tasks and generates a corresponding illustration for each prompt. To maintain visual consistency across the video, the prompts should lock in a unified animation style description (e.g., “healing-style animation,” “high color saturation”).
2.5 Keyframe Association and Video Generation Node
Turning static images into vivid animation is the most challenging part of the workflow. This step uses “first/last-frame control” to ensure continuity between video clips.
The workflow first extracts the generated images, using the preceding image as the first frame of the current clip and the following image as the last frame. It then configures a generic text-to-video LLM node (e.g., a “doubao_video_generator”-type node) that supports dual-driven video generation from both text prompts and first/last frames. By passing in the video prompt along with the associated first and last frames, the model generates dynamic footage that follows physically plausible motion while preserving image features. Here, developers can also configure parameters such as resolution (e.g., 1080P), aspect ratio (e.g., 16:9), and clip duration (e.g., 5 seconds), depending on platform capabilities.
2.6 Data Aggregation Code Node and Workflow End
After batch video generation, the workflow produces a large number of media URLs and metadata. To make this usable by downstream applications (such as automated editing tools or frontend pages), a code node is introduced for data processing.
Code nodes typically support Python or JavaScript. Here, developers can write logic to sort the scattered video clip information by timeline order, extract keyframe image URLs, and package the results into standardized JSON output. Finally, the end node returns the aggregated data to the caller.
3. Agent Workflow Optimization Strategies
When building and running the workflow above, developers may face challenges such as unstable generation results or node-level timeouts. Key recommendations:
- Strengthen LLM output fault tolerance: Beyond specifying the format in prompts, require the model to output JSON, and add JSON parsing with error-handling logic in the code node, preventing a single misplaced punctuation mark from breaking the entire workflow.
- Concurrency control and retry strategies: Multimodal generation is often time-consuming. For batch image and video nodes, set a sensible concurrent request limit to avoid API rate limiting, and configure automatic retries for critical nodes to improve overall robustness.
- Temperature tuning per node: For the script generation node, a higher Temperature value can increase content richness; for the visual script generation node, keep Temperature low to ensure precise, stable prompts.
4. Conclusion
The essence of an agent workflow is embedding human expertise and operational logic into code and LLM prompts, thereby automating complex tasks. As this educational short-video case shows, the core difficulty lies not in configuring any single node, but in orchestrating coordination between models, designing precise prompts, and ensuring lossless data transfer between nodes. With this methodology, developers can not only replicate this video-generation workflow but also extend the same approach to broader automated content production scenarios such as news broadcasting, text-to-video conversion, and e-commerce product showcases.
