Phidata (Agno) Tutorial: Build Powerful AI Agents with a Simple Framework
Building intelligent and autonomous AI agents is now easier than ever with Phidata (now known as Agno). This framework offers a simpler approach compared to CrewAI or LangGraph, while remaining powerful enough for various use cases from simple chatbots to complex multi-agent systems.
In this tutorial, we will learn how to build AI agents using Phidata/Agno from scratch, culminating in building a research agent that can search the web and write reports automatically.
What is Phidata/Agno?
Phidata is an open-source framework for building AI agents with Python. It is designed with a simplicity-first philosophy, where you can create a functional agent with just a few lines of code. Phidata recently rebranded to Agno, but the concepts and API remain consistent.
Key advantages of Phidata/Agno:
- Easy to learn: Intuitive API and comprehensive documentation
- Built-in tools: Web search, file operations, SQL, and much more
- Knowledge bases: Integration with vector databases for RAG
- Memory and storage: Agents that remember conversation context
- Multi-agent teams: Orchestrate multiple agents simultaneously
- Structured outputs: Type-safe outputs with Pydantic models
- Streaming: Real-time streaming response support
Installation and Setup
Package Installation
# Install Phidata/Agno
pip install agno
Or using the legacy name
pip install phidata
Additional dependencies for tools
pip install openai duckduckgo-search sqlalchemy pgvector
API Key Configuration
# Set environment variable for OpenAI
export OPENAIAPIKEY="sk-your-api-key-here"
Or use a .env file
echo 'OPENAIAPIKEY=sk-your-api-key-here' > .env
# Or set directly in Python
import os
os.environ["OPENAIAPIKEY"] = "sk-your-api-key-here"
Creating Your First Agent
Simple Agent
from agno.agent import Agent
from agno.models.openai import OpenAIChat
Create a simple agent
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
description="You are a helpful and friendly assistant.",
instructions=[
"Answer clearly and concisely",
"Provide well-structured responses"
],
markdown=True
)
Run the agent
agent.printresponse("Explain what machine learning is in 3 paragraphs")
Agent with Detailed System Prompt
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
description="You are a senior data scientist with 10 years of experience.",
instructions=[
"Provide technical but easy-to-understand answers",
"Include Python code examples when relevant",
"Use analogies to explain complex concepts",
"Always recommend best practices"
],
markdown=True,
showtoolcalls=True
)
response = agent.run("How do I handle imbalanced datasets?")
print(response.content)
Using Tools
Tools are the most powerful feature of Phidata/Agno. Agents can use tools to interact with the outside world such as searching the web, reading files, or querying databases.
Web Search Tool
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
Agent with web search capability
webagent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[DuckDuckGoTools()],
description="You are a research assistant that can search the internet.",
instructions=[
"Always search for the latest information before answering",
"Include information sources",
"Provide well-structured summaries"
],
showtoolcalls=True,
markdown=True
)
webagent.printresponse("What are the latest AI developments in Southeast Asia in 2026?")