video_generation.py
"""
Video Generation Agent
=======================
A WhatsApp agent that generates short videos from text descriptions
using Fal AI's text-to-video models. Demonstrates outbound video
support through the WhatsApp Cloud API.
Requires:
WHATSAPP_ACCESS_TOKEN, WHATSAPP_PHONE_NUMBER_ID
FAL_KEY
pip install fal-client
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os.app import AgentOS
from agno.os.interfaces.whatsapp import Whatsapp
from agno.tools.fal import FalTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent_db = SqliteDb(db_file="tmp/video_agent.db")
video_agent = Agent(
name="Video Generator",
model=OpenAIChat(id="gpt-5-mini"),
tools=[FalTools(model="fal-ai/hunyuan-video")],
instructions=[
"You are a video generation assistant on WhatsApp.",
"When the user describes a scene, use the generate_media tool to create a short video.",
"After generating, briefly describe what was created.",
"Keep messages short and conversational.",
],
db=agent_db,
add_history_to_context=True,
num_history_runs=3,
send_media_to_model=False,
)
# ---------------------------------------------------------------------------
# AgentOS setup
# ---------------------------------------------------------------------------
agent_os = AgentOS(
agents=[video_agent],
interfaces=[Whatsapp(agent=video_agent)],
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent_os.serve(app="video_generation:app", reload=True)
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U "agno[os]" fal-client openai
3
Export environment variables
export FAL_API_KEY="your_fal_api_key_here"
export FAL_KEY="your_fal_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
export WHATSAPP_ACCESS_TOKEN="your_whatsapp_access_token_here"
export WHATSAPP_APP_SECRET="your_whatsapp_app_secret_here"
export WHATSAPP_PHONE_NUMBER_ID="your_whatsapp_phone_number_id_here"
export WHATSAPP_VERIFY_TOKEN="your_whatsapp_verify_token_here"
$Env:FAL_API_KEY="your_fal_api_key_here"
$Env:FAL_KEY="your_fal_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:WHATSAPP_ACCESS_TOKEN="your_whatsapp_access_token_here"
$Env:WHATSAPP_APP_SECRET="your_whatsapp_app_secret_here"
$Env:WHATSAPP_PHONE_NUMBER_ID="your_whatsapp_phone_number_id_here"
$Env:WHATSAPP_VERIFY_TOKEN="your_whatsapp_verify_token_here"
4
Run the example
Save the code above as
video_generation.py, then run:python video_generation.py