FalTools 使 Agent 能够执行媒体生成任务。

先决条件

以下示例需要 fal_client 库和一个 API 密钥,您可从 Fal 获取。

pip install -U fal_client
export FAL_KEY=***

示例

以下 agent 将使用 FAL 生成用户请求的任何视频。

cookbook/tools/fal_tools.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.fal import FalTools

fal_agent = Agent(
    name="Fal Video Generator Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[FalTools("fal-ai/hunyuan-video")],
    description="You are an AI agent that can generate videos using the Fal 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,
)

fal_agent.print_response("Generate video of balloon in the ocean")

Toolkit 参数

参数类型默认值描述
api_keystrNone用于身份验证的 API 密钥。
modelstrNone用于媒体生成的模型。

Toolkit 函数

函数描述
generate_media根据用户提示生成图像或视频。
image_to_image根据文本提示转换输入图像。

开发者资源