> ## 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.

# TypeScript Async AI Agents

> A production-ready Multi AI Agents framework for TypeScript Async

PraisonAI is a production-ready Multi AI Agents framework for TypeScript Async, designed to create AI Agents to automate and solve problems ranging from simple tasks to complex challenges. It provides a low-code solution to streamline the building and management of multi-agent LLM systems, emphasising simplicity, customisation, and effective human-agent collaboration.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    User([User]) --> AgentTeam[AgentTeam]
    AgentTeam --> Agent[Agent]

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

    class Agent agent
    class AgentTeam,User tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Installation

<CodeGroup>
  ```bash npm theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  npm install praisonai
  ```

  ```bash yarn theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  yarn add praisonai
  ```
</CodeGroup>

## Usage Examples

<AccordionGroup>
  <Accordion title="Single Agent Example" icon="user" defaultOpen>
    Create and run a single agent to perform a specific task:

    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    import { Agent, AgentTeam } from 'praisonai';

    async function main() {
        // Create a simple agent (no task specified)
        const agent = new Agent({
            name: "BiologyExpert",
            instructions: "Explain the process of photosynthesis in detail.",
            verbose: true
        });

        // Run the agent
        const praisonAI = new AgentTeam({
            agents: [agent],
            tasks: ["Explain the process of photosynthesis in detail."],
            verbose: true
        });

        try {
            console.log('Starting single agent example...');
            const results = await praisonAI.start();
            console.log('\nFinal Results:', results);
        } catch (error) {
            console.error('Error:', error);
        }
    }

    main();
    ```
  </Accordion>

  <Accordion title="Multi-Agent Example" icon="users" defaultOpen>
    Create and run multiple agents working together:

    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    import { Agent, AgentTeam } from 'praisonai';

    async function main() {
        // Create multiple agents with different roles
        const researchAgent = new Agent({
            name: "ResearchAgent",
            instructions: "Research and provide detailed information about renewable energy sources.",
            verbose: true
        });

        const summaryAgent = new Agent({
            name: "SummaryAgent",
            instructions: "Create a concise summary of the research findings about renewable energy sources. Use {previous_result} as input.",
            verbose: true
        });

        const recommendationAgent = new Agent({
            name: "RecommendationAgent",
            instructions: "Based on the summary in {previous_result}, provide specific recommendations for implementing renewable energy solutions.",
            verbose: true
        });

        // Run the agents in sequence
        const praisonAI = new AgentTeam({
            agents: [researchAgent, summaryAgent, recommendationAgent],
            tasks: [
                "Research and analyze current renewable energy technologies and their implementation.",
                "Summarize the key findings from the research.",
                "Provide actionable recommendations based on the summary."
            ],
            verbose: true
        });

        try {
            console.log('Starting multi-agent example...');
            const results = await praisonAI.start();
            console.log('\nFinal Results:', results);
        } catch (error) {
            console.error('Error:', error);
        }
    }

    main();
    ```
  </Accordion>

  <Accordion title="Task-Based Agent Example" icon="list-check" defaultOpen>
    Create agents with specific tasks and dependencies:

    ```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    import { Agent, Task, Agents } from 'praisonai';

    async function main() {
        // Create agents first
        const dietAgent = new Agent({
            name: "DietAgent",
            role: "Nutrition Expert",
            goal: "Create healthy and delicious recipes",
            instructions:  # Canonical: use 'instructions' instead of 'backstory' "You are a certified nutritionist with years of experience in creating balanced meal plans.",
            verbose: true,
            instructions: `You are a professional chef and nutritionist. Create 5 healthy food recipes that are both nutritious and delicious.
    Each recipe should include:
    1. Recipe name
    2. List of ingredients with quantities
    3. Step-by-step cooking instructions
    4. Nutritional information
    5. Health benefits

    Format your response in markdown.`
        });

        const blogAgent = new Agent({
            name: "BlogAgent",
            role: "Food Blogger",
            goal: "Write engaging blog posts about food and recipes",
            instructions:  # Canonical: use 'instructions' instead of 'backstory' "You are a successful food blogger known for your ability to make recipes sound delicious and approachable.",
            verbose: true,
            instructions: `You are a food and health blogger. Write an engaging blog post about the provided recipes.
    The blog post should:
    1. Have an engaging title
    2. Include an introduction about healthy eating`
        });

        // Create tasks
        const createRecipesTask = new Task({
            name: "Create Recipes",
            description: "Create 5 healthy and delicious recipes",
            agent: dietAgent
        });

        const writeBlogTask = new Task({
            name: "Write Blog",
            description: "Write a blog post about the recipes",
            agent: blogAgent,
            dependencies: [createRecipesTask]  // This task depends on the recipes being created first
        });

        // Run the tasks
        const praisonAI = new AgentTeam({
            tasks: [createRecipesTask, writeBlogTask],
            verbose: true
        });

        try {
            console.log('Starting task-based example...');
            const results = await praisonAI.start();
            console.log('\nFinal Results:', results);
        } catch (error) {
            console.error('Error:', error);
        }
    }

    main();
    ```
  </Accordion>
</AccordionGroup>

## Running the Examples

## Quick Start

<Steps>
  <Step title="Simple Usage">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    export OPENAI_API_KEY='your-api-key'
    ```
  </Step>

  <Step title="With Configuration">
    Create a new TypeScript file (e.g., `app.ts`) with any of the above examples.
  </Step>

  <Step title="Run the Example">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    npx ts-node app.ts
    ```
  </Step>
</Steps>

## Related

<CardGroup cols={2}>
  <Card title="TypeScript" icon="js" href="/docs/js/typescript">TypeScript overview</Card>
  <Card title="Agent" icon="robot" href="/docs/js/agent">Agent configuration</Card>
</CardGroup>
