ProCodebaseProCodebase
  • ModusA Growth OS for your business, on WhatsAppKiosqSell more. Chase less.AI InterviewerAutomated screening & AI-led interviewsXperto AIAI prep companion for candidatesAI Tools HubResume builder, learning paths & more
  • Pre-Vetted DevelopersScreened, scored and ready to interviewAI-Native DevelopersSenior engineers on an hourly basis
  • Services
  • Features
  • Jobs
  • FAQs
Sign inBook a demo
  • Services
  • Features
  • Jobs
  • FAQs
Sign inBook a demo
ProCodebaseProCodebase

ProCodebase Technologies builds AI products for hiring and growth, and ships software for clients as a technical consultancy. We source, screen and deliver pre-vetted developers — so you only interview high-signal candidates.

Products

  • Modus
  • Kiosq
  • AI Interviewer
  • Xperto AI
  • AI Tools Hub

Hire & build

  • Pre-Vetted Developers
  • AI-Native Developers
  • Technical Consultancy
  • MVP Development
  • Features

Resources

  • Articles
  • Topics
  • Certifications
  • Collections
  • Jobs

Company

  • About Us
  • Contact Us
  • Book a Demo
  • FAQs

© 2026 ProCodebase Technologies. All rights reserved.

  • Privacy Policy
  • Terms & Conditions
  • Refund & Cancellation

Level Up Your Skills with Xperto-AI

A multi-AI agent platform that helps you level up your development skills and ace your interview preparation to secure your dream job.

Launch Xperto-AI

Building Your First Basic Agent Using Phidata Framework

author
Generated by
ProCodebase AI

12/01/2025

generative-ai

Sign in to read full article

Introduction

In the rapidly evolving world of generative AI, creating intelligent agents has become more accessible than ever. The Phidata framework offers a streamlined approach to building AI agents, making it an excellent choice for beginners and experienced developers alike. In this tutorial, we'll walk through the process of creating your first basic agent using Phidata.

Prerequisites

Before we dive in, make sure you have:

  1. Python 3.7 or later installed
  2. An OpenAI API key
  3. Basic familiarity with Python programming

Setting Up Your Environment

First, let's set up our project environment:

  1. Create a new directory for your project:

    mkdir my_first_agent cd my_first_agent
  2. Create a virtual environment and activate it:

    python -m venv venv source venv/bin/activate

On Windows, use venv\Scripts\activate


3. Install Phidata:
```bash
pip install phidata

Creating Your First Agent

Now that we have our environment set up, let's create our first agent:

  1. Create a new Python file named my_agent.py:
    from phi.llm.openai import OpenAIChat from phi.agent import Agent

Initialize the OpenAI chat model

llm = OpenAIChat(model="gpt-3.5-turbo")

Define our agent

my_agent = Agent( name="MyFirstAgent", description="A helpful assistant that can answer questions and provide information.", llm=llm, tools=[],

We'll leave this empty for now

)

Run the agent

my_agent.run("Hello! Can you tell me what day it is?")


2. Set your OpenAI API key as an environment variable:
```bash
export OPENAI_API_KEY=your_api_key_here
  1. Run your agent:
    python my_agent.py

Congratulations! You've just created and run your first AI agent using Phidata.

Understanding the Code

Let's break down what's happening in our my_agent.py file:

  1. We import the necessary components from Phidata.
  2. We initialize an OpenAIChat instance, which will be our language model.
  3. We create an Agent instance, giving it a name, description, and the language model to use.
  4. We call the run method on our agent with a simple question.

Enhancing Your Agent

Now that we have a basic agent, let's add some capabilities:

  1. Add a tool to get the current date:

    from datetime import datetime def get_current_date(): return datetime.now().strftime("%Y-%m-%d") my_agent = Agent( name="MyFirstAgent", description="A helpful assistant that can answer questions and provide the current date.", llm=llm, tools=[get_current_date], )
  2. Run the agent with a more specific question:

    my_agent.run("What is today's date?")

Now your agent can provide the current date when asked!

Experimenting Further

Here are some ideas to expand your agent's capabilities:

  1. Add more tools, such as a calculator or a weather API.
  2. Implement memory to allow your agent to remember previous interactions.
  3. Create a simple chat interface to interact with your agent.

Conclusion

Building your first AI agent with Phidata is just the beginning. As you become more familiar with the framework, you'll be able to create increasingly complex and capable agents. Remember to always consider ethical implications and potential biases when developing AI systems.

Happy coding, and enjoy your journey into the world of AI agents!

Popular tags

generative-aiphidataai-agents

Share now!

Like & bookmark

Related collections

  • GenAI Concepts for non-AI/ML developers

    06/10/2024 · Generative AI

  • CrewAI Multi-Agent Platform

    27/11/2024 · Generative AI

  • LLM Frameworks and Toolkits

    03/12/2024 · Generative AI

  • Microsoft AutoGen Agentic AI Framework

    27/11/2024 · Generative AI

  • ChromaDB Mastery: Building AI-Driven Applications

    12/01/2025 · Generative AI

Related articles

  • Foundations of Generative AI Agents

    25/11/2024 · Generative AI

  • Enhancing Generative AI

    25/11/2024 · Generative AI

  • Implementing Tasks and Goals for Agents in CrewAI

    27/11/2024 · Generative AI

  • Basic Agent Types in AutoGen

    27/11/2024 · Generative AI

  • Chain Patterns for Complex Tasks in Generative AI

    24/12/2024 · Generative AI

  • Designing Multi-Agent Systems with CrewAI

    27/11/2024 · Generative AI

  • Navigating the Frontiers of Advanced Reasoning in Generative AI

    25/11/2024 · Generative AI

Popular category

  • Python
  • Generative AI
  • Machine Learning
  • ReactJS
  • System Design