> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 复制

**ReplicateTools** 使 Agent 能够使用 [Replicate 平台](https://replicate.com/) 生成媒体。

## 先决条件

```shell theme={null}
export REPLICATE_API_TOKEN=***
```

下面的示例需要 `replicate` 库。要安装 Replicate 客户端，请运行以下命令：

```shell theme={null}
pip install -U replicate
```

## 示例

下面的 Agent 将使用 Replicate 来生成用户请求的图像或视频。

```python cookbook/tools/replicate_tool.py theme={null}
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.replicate import ReplicateTools

"""创建专门用于 Replicate AI 内容生成的 Agent"""

image_agent = Agent(
    name="Image Generator Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[ReplicateTools(model="luma/photon-flash")],
    description="You are an AI agent that can generate images using the Replicate API.",
    instructions=[
        "When the user asks you to create an image, use the `generate_media` tool to create the image.",
        "Return the URL as raw to the user.",
        "Don't convert image URL to markdown or anything else.",
    ],
    markdown=True,
    debug_mode=True,
    show_tool_calls=True,
)

image_agent.print_response("Generate an image of a horse in the dessert.")
```

## Toolkit 参数

| 参数        | 类型    | 默认                 | 说明                                       |
| --------- | ----- | ------------------ | ---------------------------------------- |
| `api_key` | `str` | `None`             | 如果您想手动提供 Replicate API 密钥。               |
| `model`   | `str` | `minimax/video-01` | 要使用的 Replicate 模型。在 Replicate 平台上了解更多信息。 |

## Toolkit 函数

| 函数               | 说明                  |
| ---------------- | ------------------- |
| `generate_media` | 从提示生成图像或视频。输出取决于模型。 |

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/replicate.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/replicate_tools.py)
