Creating Your First Agent

A step-by-step guide to building your first AI agent

Let’s build your first AI agent in 5 minutes! Follow along step by step.

Diagram

What We’ll Build

👤 You

🤖 Research Assistant

✅ Helpful Answers


Step-by-Step Guide

  1. Install PraisonAI

    Open your terminal and run:

    bash
    pip install praisonaiagents
  2. Set Your API Key

    Set your OpenAI API key:

    bash
    export OPENAI_API_KEY=your_key_here
  3. Create Your Agent File

    Create a new file called my_agent.py:

    python
    from praisonaiagents import Agent
    
    # Create your first agent
    agent = Agent(
        name="ResearchAssistant",
        instructions="You are a helpful research assistant. Explain things simply and clearly."
    )
    
    # Ask it a question
    agent.start("Explain how solar panels work in simple terms")
  4. Run Your Agent
    bash
    python my_agent.py

    You should see the agent’s response explaining solar panels!


How It Works

Diagram

Agent Flow

📋 Instructions

🤖 Agent

❓ Question

🧠 LLM

💬 Response

StepWhat Happens
InstructionsTell the agent who it is and how to behave
QuestionYour message or task
LLMAI model processes everything
ResponseAgent returns the answer

Try Different Agents

Coding Helper

python
from praisonaiagents import Agent

coder = Agent(
    name="CodeHelper",
    instructions="You are a Python expert. Explain code simply and provide working examples."
)

coder.start("How do I read a CSV file in Python?")

Creative Writer

python
from praisonaiagents import Agent

writer = Agent(
    name="StoryWriter",
    instructions="You write short, engaging stories with vivid descriptions."
)

writer.start("Write a short story about a robot learning to paint")

Math Tutor

python
from praisonaiagents import Agent

tutor = Agent(
    name="MathTutor",
    instructions="You explain math concepts step by step. Use simple language."
)

tutor.start("Explain how percentages work")

Complete Example

python
from praisonaiagents import Agent

# Create a research assistant
assistant = Agent(
    name="ResearchAssistant",
    instructions="""You are a helpful research assistant.

When answering:
- Be concise and clear
- Use bullet points when helpful
- Explain complex topics simply
- Admit when you don't know something"""
)

# Ask multiple questions
assistant.start("What are the benefits of exercise?")
assistant.start("How does the internet work?")
assistant.start("Explain climate change in simple terms")

Troubleshooting


What’s Next?

Add Tools

Give your agent superpowers like web search and calculations

Add Memory

Let your agent remember conversations

Add Knowledge

Give your agent access to your documents

Build Teams

Create multiple agents that work together


Next: Adding Tools to Agents

Learn how to give your agents superpowers with tools.