What We’ll Build
This guide shows how to build a fal.ai plugin that lets your agent generate 6-second, 768p videos from text prompts using the MiniMax Hailuo-02 model. For architectural concepts, see Plugin Architecture. You’ll learn:- Actions (what the agent can DO)
- Progressive development (start simple, organize as you grow)
- Local plugin testing (character.plugins array method)
- Plugin testing (component and E2E tests)
Step 1: Quick Start
Create Project and Plugin
Create a project with a plugin inside using CLI commands:Create project
Terminal
- Database: PgLite (perfect for local development)
- Model: OpenAI
Terminal
Create plugin inside project
Terminal
Connect and Test
Step 2: Development
Research the API
Let’s research what we want to build by exploring fal.ai for a good text-to-video model. MiniMax Hailuo-02 Text to Video looks pretty good.- Navigate to the JavaScript/Typescript section of the docs to see how to call the API:
- Install:
bun add @fal-ai/client - Import:
import { fal } from "@fal-ai/client" - Use:
fal.subscribe("model-endpoint", { input: {...} }) - Returns:
{ data, requestId }
- Install:
Edit Default Plugin Template
Add fal.ai dependency
Terminal
Study the template structure
Open
plugin-fal-ai/src/plugin.ts to see the sample code patterns for plugins:quickAction- example Action (what agent can DO)quickProvider- example Provider (gives agent CONTEXT)StarterService- example Service (manages state/connections)- Plugin events, routes, models - other comprehensive patterns
Create your text-to-video action using plugin patterns
Copy the plugin file and rename it to create your action:Now let’s edit the example plugin into our generateVideo action:Add the fal.ai import (from the fal.ai docs):Update the action identity for video generation:Replace validation with API key check:Replace hello world logic with video generation:Update examples for video conversations:
Terminal
src/actions/generateVideo.ts
Update index.ts to use your action
Finally, update
src/index.ts to use our new plugin:src/index.ts
You can reference
plugin.ts as well as other plugins from the Plugin Registry to see other plugin component examples (providers, services, etc.) as you expand your plugin.Add Configuration
Get your fal.ai API key
Get an API key from fal.ai and copy/paste it into your .env:
.env
Step 3: Testing
Test Plugin Functionality
Verify your plugin works as expected:Test the updated plugin
First rebuild your plugin to effect our changes, then start from project root:
Terminal
Plugin Component Tests
Plugins come default with component and E2E tests. Let’s add custom component tests:Plugin E2E Tests
Let’s also add a custom E2E test:Add an E2E test
Update
src/__tests__/e2e/plugin-fal-ai.e2e.ts:src/__tests__/e2e/plugin-fal-ai.e2e.ts
Step 4: Possible Next Steps
Congratulations! You now have a working video generation plugin. Here are some ways you can improve it:Enhance Your Action
- Add more similes - Handle requests like “animate this”, “video of”, “show me a clip of”
- Better examples - Add more conversation examples so Eliza learns different chat patterns
- Error handling - Handle rate limits, invalid prompts, or API timeouts
Add Plugin Components
- Providers - Give your agent context about recent videos or video history
- Evaluators - Track analytics, log successful generations, or rate video quality
- Services - Add queueing for multiple video requests or caching for common prompts

