Code

cookbook/tools/morph_tools.py
from agno.agent import Agent
from agno.tools.models.morph import MorphTools

agent = Agent(
    instructions=[
        "You are a code editing assistant using Morph's advanced AI capabilities",
        "Help users modify, improve, and refactor their code intelligently",
        "Apply code changes efficiently while maintaining code quality",
    ],
    tools=[MorphTools()],
    markdown=True,
)

agent.print_response("Refactor this Python function to be more efficient and add type hints")

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Set your API keys

export MORPH_API_KEY=your-morph-api-key
export OPENAI_API_KEY=xxx
3

Install libraries

pip install -U openai agno
4

Run Agent

python cookbook/tools/morph_tools.py