Replicate
Generate images and videos from text prompts with ReplicateTools and the Replicate platform.
ReplicateTools enables an Agent to generate media using the Replicate platform.
Prerequisites
export REPLICATE_API_KEY=***
export REPLICATE_API_TOKEN=***Set both variables to the same value. The toolkit reads REPLICATE_API_KEY while the replicate client authenticates with REPLICATE_API_TOKEN.
The following example requires the replicate and openai libraries.
uv pip install -U agno replicate openaiExample
The following agent uses Replicate to generate images or videos requested by the user. This older cookbook excerpt uses gpt-4o for orchestration; the current main cookbook uses OpenAIChat(id="gpt-5.6-luna"). Use that model setting when following main.
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"""
image_agent = Agent(
name="Image Generator Agent",
model=OpenAIChat(id="gpt-4o"),
tools=[ReplicateTools(model="luma/photon-flash", enable_generate_media=True)],
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,
)
image_agent.print_response("Generate an image of a horse in the dessert.")Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | Stored/checked by Agno; does not configure the module-level SDK client. Also set REPLICATE_API_TOKEN. |
model | str | minimax/video-01 | The replicate model to use. Find out more on the Replicate platform. |
enable_generate_media | bool | True | Enable the generate_media functionality. |
all | bool | False | Enable all functionality. |
Toolkit Functions
| Function | Description |
|---|---|
generate_media | Generate either an image or a video from a prompt. The output depends on the model. |