Replicate
ReplicateTools enables an Agent to generate media using the Replicate platform.
Prerequisites
1export REPLICATE_API_TOKEN=***The following example requires the replicate library. To install the Replicate client, run the following command:
1uv pip install -U replicateExample
The following agent will use Replicate to generate images or videos requested by the user.
1from kern.agent import Agent2from kern.models.openai import OpenAIResponses3from kern.tools.replicate import ReplicateTools45"""Create an agent specialized for Replicate AI content generation"""67image_agent = Agent(8 name="Image Generator Agent",9 model=OpenAIResponses(id="gpt-5.2"),10 tools=[ReplicateTools(model="luma/photon-flash")],11 description="You are an AI agent that can generate images using the Replicate API.",12 instructions=[13 "When the user asks you to create an image, use the `generate_media` tool to create the image.",14 "Return the URL as raw to the user.",15 "Don't convert image URL to markdown or anything else.",16 ],17 markdown=True,18 debug_mode=True,19 )2021image_agent.print_response("Generate an image of a horse in the dessert.")Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | If you want to manually supply the Replicate API key. |
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. |
Developer Resources
- View Tools