> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Mini AI Agents

> Learn how to create simple yet powerful AI agents in just a few lines of code.

## Quick Start

Create multiple AI agents that can work together in just a few lines of code!

<Tabs>
  <Tab title="Code">
    <Steps>
      <Step title="Install Package">
        First, install the PraisonAI Agents package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonaiagents duckduckgo_search
        ```
      </Step>

      <Step title="Set API Key">
        Set your OpenAI API key as an environment variable in your terminal:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        export OPENAI_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="Create Your Agents">
        <CodeGroup>
          ```python Single Agent theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
          from praisonaiagents import Agent, AgentTeam
          summarise_agent = Agent(instructions="Summarise Photosynthesis")
          agents = AgentTeam(agents=[summarise_agent])
          agents.start()
          ```

          ```python Multiple Agents theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
          # Agent with Internet Search Tool
          from praisonaiagents import Agent, AgentTeam
          research_agent = Agent(instructions="Research about AI 2024", tools=[Tools.internet_search])
          summarise_agent = Agent(instructions="Summarise research agent's findings")
          agents = AgentTeam(agents=[research_agent, summarise_agent])
          agents.start()
          ```
        </CodeGroup>
      </Step>

      <Step title="Run Your Agents">
        Execute your agents by running:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        python app.py
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="No Code">
    <Steps>
      <Step title="Install Package">
        First, install the PraisonAI Agents package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonaiagents duckduckgo_search
        ```
      </Step>

      <Step title="Set API Key">
        Set your OpenAI API key as an environment variable in your terminal:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        export OPENAI_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="Create Your Agents">
        <CodeGroup>
          ```yaml Single Agent theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
          # Create a new file `agents.yaml` with the following content:
          agents:  # Canonical
            summarise_agent
              instructions: Summarise Photosynthesis
          ```

          ```yaml Multiple Agents theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
          # Create a new file `agents.yaml` with the following content:
          # Agent with Internet Search Tool
          agents:  # Canonical
            research_agent
              instructions: Research about AI 2024
              tools:
                - internet_search
            summarise_agent
              instructions: Summarise research agent's findings
          ```
        </CodeGroup>
      </Step>

      <Step title="Run Your Agents">
        Execute your agents by running:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        python app.py
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

<Note>
  **Prerequisites**

  * Python 3.10 or higher
  * OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys). Use Other models using [this guide](/models).
</Note>

<br />

<div className="relative w-full aspect-video">
  <iframe className="absolute top-0 left-0 w-full h-full" src="https://www.youtube.com/embed/OkvYp5aAGSg" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />
</div>

<br />

## Understanding Mini AI Agents

<Card title="What are Mini AI Agents?" icon="question">
  Mini AI Agents are simplified yet powerful AI agents that can:

  * Work together to accomplish tasks
  * Use tools like internet search
  * Process and summarize information
  * Execute tasks sequentially
</Card>

## Key Components

<CardGroup cols={2}>
  <Card title="Agent" icon="user-robot">
    Individual AI agents with specific roles and capabilities

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Agent(instructions="Your agent's role description")
    ```
  </Card>

  <Card title="Tools" icon="wrench">
    Built-in tools that agents can use

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    tools=[Tools.internet_search]
    ```
  </Card>

  <Card title="Agents Manager" icon="users">
    Coordinates multiple agents

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    AgentTeam(agents=[agent1, agent2])
    ```
  </Card>

  <Card title="Sequential Flow" icon="arrow-right">
    Agents work in sequence, passing results to each other
  </Card>
</CardGroup>

## Available Tools

<CardGroup cols={2}>
  <Card title="Internet Search" icon="search">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Tools.internet_search
    ```

    Search the internet using DuckDuckGo

    <Note>
      Requires: `pip install duckduckgo_search`
    </Note>
  </Card>
</CardGroup>

## Custom Instructions

<CodeGroup>
  ```python Basic theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  # Simple instructions
  research_agent = Agent(
      instructions="Research about climate change"
  )
  ```

  ```python Advanced theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  # Detailed instructions
  research_agent = Agent(
      instructions="""
      You are a research agent focused on gathering information about:
      1. Latest AI developments in 2024
      2. Major breakthroughs in machine learning
      3. New AI applications in industry
      
      Provide detailed and accurate information from reliable sources.
      """
  )
  ```
</CodeGroup>

## Best Practices

<AccordionGroup>
  <Accordion title="Agent Instructions">
    Write clear and specific instructions:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    # Good
    Agent(instructions="Research and analyze the latest AI developments in 2024")

    # Too vague
    Agent(instructions="Research AI")
    ```
  </Accordion>

  <Accordion title="Tool Usage">
    Provide tools only to agents that need them:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    # Research agent needs search
    research_agent = Agent(
        instructions="Research AI",
        tools=[Tools.internet_search]
    )

    # Summary agent doesn't need search
    summary_agent = Agent(
        instructions="Summarize findings"
    )
    ```
  </Accordion>
</AccordionGroup>

## Common Patterns

### Research and Analysis

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Research agent
researcher = Agent(
    instructions="Research latest developments in quantum computing",
    tools=[Tools.internet_search]
)

# Analysis agent
analyst = Agent(
    instructions="Analyze and explain the research findings in simple terms"
)

agents = AgentTeam(agents=[researcher, analyst])
```

### Information Processing

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Data collector
collector = Agent(
    instructions="Collect information about renewable energy",
    tools=[Tools.internet_search]
)

# Summarizer
summarizer = Agent(
    instructions="Create a concise summary of the collected information"
)

# Report writer
writer = Agent(
    instructions="Write a detailed report based on the summary"
)

agents = AgentTeam(agents=[collector, summarizer, writer])
```

## Troubleshooting

<CardGroup cols={2}>
  <Card title="Tool Not Available" icon="triangle-exclamation">
    If using `Tools.internet_search`, install required package:

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install duckduckgo_search
    ```
  </Card>

  <Card title="Agent Communication" icon="comments">
    Ensure agent instructions are clear and complementary
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Advanced Agents" icon="graduation-cap" href="./advanced">
    Learn about advanced agent configurations
  </Card>

  <Card title="Custom Tools" icon="screwdriver-wrench" href="./tools">
    Create your own agent tools
  </Card>
</CardGroup>

<Note>
  Mini AI Agents are designed to be simple yet powerful. They're perfect for quick prototypes and straightforward automation tasks.
</Note>
