Skip to main content
Create an Agent, set one API key, and run it in three lines of code.
from praisonaiagents import Agent

agent = Agent(instructions="Summarise Photosynthesis")
agent.start()
Pick the provider whose key you already have — PraisonAI selects the matching model automatically.

Basic

1

Install Package

Install the PraisonAI Agents package:
pip install praisonaiagents
2

Set API Key

Set the key for whichever provider you use — PraisonAI picks the right model automatically:
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
praisonai "hello"
No --model flag needed — the matching provider’s default model is selected automatically. See Provider Auto-Detection for the full list.
3

Create Agents

Create app.py:
from praisonaiagents import Agent, AgentTeam

# Create a simple agent
summarise_agent = Agent(instructions="Summarise Photosynthesis")

# Run the agent
team = AgentTeam(agents=[summarise_agent])
team.start()
from praisonaiagents import Agent, AgentTeam

# Create agents with specific roles
diet_agent = Agent(
    instructions="Give me 5 healthy food recipes",
)

blog_agent = Agent(
    instructions="Write a blog post about the food recipes",
)

# Run multiple agents
team = AgentTeam(agents=[diet_agent, blog_agent])
team.start()
For the absolute shortest Python entry point — no class instantiation — use praisonai.run("agents.yaml"). See the one-liner guide.
4

Run Agents

Execute your script:
python app.py
You’ll see:
  • Agent initialization
  • Task execution progress
  • Final results
You have successfully CreatedAI Agents and made them work for you!
Prerequisites
  • Python 3.10 or higher
  • An API key for any supported provider (OpenAI, Anthropic, Google, Groq, Cohere) or a running Ollama instance — OpenAI is not required
  • For the full list of providers, see Models
Don’t have an OpenAI key? PraisonAI picks a default model that matches whichever provider credential you do have set — set ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, or run a local OLLAMA_HOST and the same praisonai command works without --model. Full precedence.

Advanced

Providing Detailed Tasks to Agents (Optional)

1

Install PraisonAI

Install the core package:
Terminal
pip install praisonaiagents
2

Configure Environment

Terminal
export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
Generate your OpenAI API key from OpenAI Use other LLM providers like Ollama, Anthropic, Groq, Google, etc. Please refer to the Models for more information.
3

Create Agent

Create app.py:
from praisonaiagents import Agent, Task, AgentTeam

# Create an agent
researcher = Agent(
    name="Researcher",
    role="Senior Research Analyst",
    goal="Uncover cutting-edge developments in AI",
    backstory="You are an expert at a technology research group",
    llm="gpt-4o"
)

# Define a task
task = Task(
    name="research_task",
    description="Analyze 2024's AI advancements",
    expected_output="A detailed report",
    agent=researcher
)

# Run the agents
team = AgentTeam(
    agents=[researcher],
    tasks=[task]
)

result = team.start()
from praisonaiagents import Agent, Task, AgentTeam

# Create multiple agents
researcher = Agent(
    name="Researcher",
    role="Senior Research Analyst",
    goal="Uncover cutting-edge developments in AI",
    backstory="You are an expert at a technology research group",
    llm="gpt-4o"
)

writer = Agent(
    name="Writer",
    role="Tech Content Strategist",
    goal="Craft compelling content on tech advancements",
    backstory="You are a content strategist",
    llm="gpt-4o"
)

# Define multiple tasks
task1 = Task(
    name="research_task",
    description="Analyze 2024's AI advancements",
    expected_output="A detailed report",
    agent=researcher
)

task2 = Task(
    name="writing_task",
    description="Create a blog post about AI advancements",
    expected_output="A blog post",
    agent=writer
)

# Run with hierarchical process
team = AgentTeam(
    agents=[researcher, writer],
    tasks=[task1, task2],
    process="hierarchical",
    manager_llm="gpt-4o"
)

result = team.start()
4

Start Agents

Execute your script:
Terminal
python app.py
You should see:
  • Agent initialization
  • Agents progress
  • Final results
  • Generated report

Creating Custom Tool for Agents (Optional)

Tools makes the Agent powerful.
More information about tools can be found in the Tools section.
1

Install PraisonAI

Install the core package and duckduckgo_search package:
Terminal
pip install praisonai duckduckgo_search
2

Create Tools and Agents

from praisonaiagents import Agent, Task, AgentTeam
from duckduckgo_search import DDGS
from typing import List, Dict

# 1. Tool
def internet_search_tool(query: str) -> List[Dict]:
    """
    Perform Internet Search
    """
    results = []
    ddgs = DDGS()
    for result in ddgs.text(keywords=query, max_results=5):
        results.append({
            "title": result.get("title", ""),
            "url": result.get("href", ""),
            "snippet": result.get("body", "")
        })
    return results

# 2. Agent
data_agent = Agent(
    name="DataCollector",
    role="Search Specialist",
    goal="Perform internet searches to collect relevant information.",
    backstory="Expert in finding and organising internet data.",
    tools=[internet_search_tool],
    reflection=False
)

# 3. Tasks
collect_task = Task(
    description="Perform an internet search using the query: 'AI job trends in 2024'. Return results as a list of title, URL, and snippet.",
    expected_output="List of search results with titles, URLs, and snippets.",
    agent=data_agent,
    name="collect_data",
)

# 4. Start Agents
team = AgentTeam(
    agents=[data_agent],
    tasks=[collect_task],
    process="sequential"
)

team.start()
3

Start Agents

Run your script:
Terminal
python app.py

How It Works

An Agent takes your instructions, calls the LLM behind the scenes, and returns the result.

Best Practices

Export OPENAI_API_KEY (or your provider’s key) in your shell or a .env file. Never paste the raw string into Agent(llm=...).
Agent(instructions="…").start() is the shortest working agent. Add name, role, tools, or a full Task only when you need them.
PraisonAI picks the right default for whichever provider credential you set. See Provider Auto-Detection.
Give an agent a plain Python function via tools=[...] when it needs to search, fetch, or compute. Keep tool functions small and typed.

Models

Choose an LLM provider and model.

Tools

Extend agents with functions and integrations.