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

# Building a Single Agent

> Learn how to create and configure a single AI agent

Create one focused agent with instructions, tools, and memory—then iterate from a single prompt.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
)
agent.start("Say hello in one sentence.")
```

The user sends a prompt; the agent calls the model (and tools if configured) and returns text.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
```

This guide walks you through creating your first AI agent with PraisonAI.

## Quick Start

<Steps>
  <Step title="Install">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents
    export OPENAI_API_KEY=your_api_key
    ```
  </Step>

  <Step title="Create your first agent">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant.",
    )

    result = agent.start("Hello! What can you help me with?")
    print(result)
    ```
  </Step>
</Steps>

## Prerequisites

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install praisonaiagents
```

Set your API key:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export OPENAI_API_KEY="your-api-key"
```

## Basic Agent

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# Create a simple agent
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant."
)

# Run the agent
result = agent.start("Hello! What can you help me with?")
print(result)
```

## Agent with Custom Role

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Researcher",
    role="Senior Research Analyst",
    goal="Provide accurate and comprehensive research",
    backstory="You are an experienced researcher with expertise in AI and technology.",
    instructions="Always cite sources and provide balanced perspectives."
)

result = agent.start("What are the latest trends in AI?")
print(result)
```

## Agent with Tools

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents import internet_search

agent = Agent(
    name="Web Researcher",
    instructions="Search the web to find accurate information.",
    tools=[internet_search]
)

result = agent.start("Find the latest news about OpenAI")
print(result)
```

## Agent with Memory

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Memory

# Create memory instance
memory = Memory()

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant with memory.",
    memory=memory
)

# First conversation
agent.start("My name is Alice")

# Agent remembers the name
result = agent.start("What's my name?")
print(result)  # "Your name is Alice"
```

## Agent Configuration Options

| Parameter      | Type     | Description                               |
| -------------- | -------- | ----------------------------------------- |
| `name`         | `str`    | Agent name                                |
| `role`         | `str`    | Agent's role description                  |
| `goal`         | `str`    | What the agent aims to achieve            |
| `backstory`    | `str`    | Background context for the agent          |
| `instructions` | `str`    | System instructions                       |
| `model`        | `str`    | LLM model to use (default: `gpt-4o-mini`) |
| `tools`        | `list`   | List of tools available to the agent      |
| `memory`       | `Memory` | Memory instance for persistence           |
| `verbose`      | `bool`   | Enable verbose logging                    |

## Using Different Models

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# OpenAI
agent = Agent(name="GPT Agent", llm="gpt-4o")

# Anthropic
agent = Agent(name="Claude Agent", llm="claude-3-5-sonnet-20241022")

# Ollama (local)
agent = Agent(name="Local Agent", llm="ollama/llama3.2")

# Google
agent = Agent(name="Gemini Agent", llm="gemini/gemini-2.0-flash")
```

## Chat Mode

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="ChatBot",
    instructions="You are a friendly chatbot."
)

# Multi-turn conversation
messages = [
    {"role": "user", "content": "Hi!"},
    {"role": "assistant", "content": "Hello! How can I help?"},
    {"role": "user", "content": "Tell me a joke"}
]

result = agent.chat(messages)
print(result)
```

## Best Practices

<AccordionGroup>
  <Accordion title="Write specific instructions">
    Clear, specific instructions lead to more consistent and useful agent behavior.
  </Accordion>

  <Accordion title="Add tools for external capabilities">
    Use tools to extend what your agent can do - search, code execution, file operations, and more.
  </Accordion>

  <Accordion title="Enable memory for context">
    Add `memory=True` for agents that need to remember information across multiple turns.
  </Accordion>

  <Accordion title="Use gpt-4o-mini for cost efficiency">
    Start with `llm='gpt-4o-mini'` for testing - switch to `gpt-4o` when you need more capability.
  </Accordion>
</AccordionGroup>

## Next Steps

* [Multi-Agent Systems](/docs/guides/multi-agent) - Build systems with multiple agents
* [Adding Tools](/docs/tools) - Extend agent capabilities
* [Agent Module Reference](/docs/sdk/praisonaiagents/agent/agent) - Full API reference

## Related

<CardGroup cols={2}>
  <Card title="Multi-Agent Systems" icon="users" href="/docs/guides/multi-agent">
    Orchestrate multiple agents working together
  </Card>

  <Card title="Tools" icon="wrench" href="/docs/tools">
    Extend your agent with tools
  </Card>
</CardGroup>
