Generate Video using Replicate

This agent takes a text input and responds with a video output.

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.replicate import ReplicateTools

"""Create an agent specialized for Replicate AI content generation"""

video_agent = Agent(
    name="Video Generator Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[
        ReplicateTools(
            model="tencent/hunyuan-video:847dfa8b01e739637fc76f480ede0c1d76408e1d694b830b5dfb8e547bf98405"
        )
    ],
    description="You are an AI agent that can generate videos using the Replicate API.",
    instructions=[
        "When the user asks you to create a video, use the `generate_media` tool to create the video.",
        "Return the URL as raw to the user.",
        "Don't convert video URL to markdown or anything else.",
    ],
    markdown=True,
    debug_mode=True,
    show_tool_calls=True,
)

video_agent.run("Generate a video of a horse in the dessert.")
for video in video_agent.run_response.videos:
    print("Video File URL:", video.url)

Usage

1

Install libraries

pip install -U agno openai
2

Export API keys

export OPENAI_API_KEY=***
export REPLICATE_API_KEY=***
3

Run the agent

python video_input.py