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

# LangChain Agents

> Learn how to use LangChain tools and utilities with PraisonAI agents.

Use LangChain community tools and utilities directly on PraisonAI agents — no adapter layer required.

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

wiki = WikipediaAPIWrapper()
agent = Agent(name="Researcher", tools=[wiki.run], instructions="Answer with Wikipedia")
agent.start("Summarise quantum computing in two paragraphs")
```

The user asks a research question; LangChain tools run inside the PraisonAI agent loop.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    A[PraisonAI Agent] --> T[LangChain Tool]
    T --> S[Wikipedia / YouTube / …]
    S --> R[Grounded response]

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

    class A agent
    class T tool
    class S,R source

```

## How It Works

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as LangChain Agents

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result    Agent-->>User: Response
```

## Quick Start

<Tabs>
  <Tab title="Code">
    <Steps>
      <Step title="Install Package">
        First, install the required packages:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install praisonaiagents langchain-community wikipedia
        ```
      </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="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
        ```
      </Step>

      <Step title="Create a file">
        Create a new file `app.py` with the basic setup:

        <CodeGroup>
          ```python Single Tool theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
          from praisonaiagents import Agent, Task, AgentTeam
          from langchain_community.utilities import WikipediaAPIWrapper

          # Create an agent with Wikipedia tool
          agent = Agent(
              name="WikiAgent",
              role="Research Assistant",
              goal="Search Wikipedia for accurate information",
              backstory="I am an AI assistant specialized in Wikipedia research",
              tools=[WikipediaAPIWrapper],
              reflection=False
          )

          # Create a research task
          task = Task(
              name="wiki_search",
              description="Research 'Artificial Intelligence' on Wikipedia",
              expected_output="Comprehensive information from Wikipedia articles",
              agent=agent
          )

          # Create and start the workflow
          agents = AgentTeam(
              agents=[agent],
              tasks=[task]
          )

          agents.start()
          ```

          ```python Multiple Tools theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
          from praisonaiagents import Agent, Task, AgentTeam
          from langchain_community.tools import YouTubeSearchTool
          from langchain_community.utilities import WikipediaAPIWrapper

          # Create YouTube search agent
          agent = Agent(
              name="SearchAgent",
              role="Research Assistant",
              goal="Search for information from YouTube",
              backstory="I am an AI assistant that can search YouTube for relevant videos.",
              tools=[YouTubeSearchTool],
              reflection=False
          )

          # Create Wikipedia research agent
          agent2 = Agent(
              name="WikiAgent",
              role="Research Assistant",
              goal="Search for information from Wikipedia",
              backstory="I am an AI assistant that can search Wikipedia for accurate information.",
              tools=[WikipediaAPIWrapper],
              reflection=False
          )

          # Create YouTube search task
          task = Task(
              name="search_task",
              description="Search for information about 'AI advancements' on YouTube",
              expected_output="Relevant information from YouTube videos",
              agent=agent
          )

          # Create Wikipedia research task
          task2 = Task(
              name="wiki_task",
              description="Search for information about 'AI advancements' on Wikipedia",
              expected_output="Comprehensive information from Wikipedia articles",
              agent=agent2
          )

          # Create and start the workflow
          agents = AgentTeam(
              agents=[agent, agent2],
              tasks=[task, task2]
          )

          agents.start()
          ```
        </CodeGroup>
      </Step>

      <Step title="Start Agents">
        Type this in your terminal to run your agents:

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

  <Tab title="No Code">
    <Steps>
      <Step title="Install Package">
        (Upcoming Feature)
        Install the PraisonAI package:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        pip install "praisonai"
        ```
      </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="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"
        ```
      </Step>

      <Step title="Create a file">
        Create a new file `agents.yaml` with the basic setup:

        ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        framework: praisonai
        process: sequential
        agents:  # Canonical: use 'agents' instead of 'roles'
          researcher:
            name: SearchAgent
            role: Research Assistant
            goal: Search for information from multiple sources
            instructions:  # Canonical: use 'instructions' instead of 'backstory' I am an AI assistant that can search YouTube and Wikipedia.
            tools:
              - youtube_search
              - wikipedia
            tasks:
              search_task:
                name: search_task
                description: Search for information about 'AI advancements' on both YouTube and Wikipedia
                expected_output: Combined information from YouTube videos and Wikipedia articles
        ```
      </Step>

      <Step title="Start Agents">
        Type this in your terminal to run your agents:

        ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
        praisonai agents.yaml
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

<Note>
  **Requirements**

  * Python 3.10 or higher
  * OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys)
  * LangChain compatible tools and utilities
</Note>

## Understanding LangChain Integration

<Card title="What is LangChain Integration?" icon="question">
  LangChain integration enables agents to:

  * Use LangChain's extensive tool ecosystem
  * Access various data sources and APIs
  * Leverage pre-built utilities and wrappers
  * Combine multiple tools in a single agent
  * Extend agent capabilities with community tools
</Card>

## Features

<CardGroup cols={2}>
  <Card title="Tool Integration" icon="plug">
    Seamlessly use LangChain tools with PraisonAI agents.
  </Card>

  <Card title="Multiple Sources" icon="database">
    Access various data sources through LangChain utilities.
  </Card>

  <Card title="Community Tools" icon="users">
    Leverage the extensive LangChain community ecosystem.
  </Card>

  <Card title="Custom Tools" icon="wrench">
    Create and integrate custom LangChain tools.
  </Card>
</CardGroup>

## Best Practices

<AccordionGroup>
  <Accordion title="Install tool dependencies per source">
    Each LangChain utility pulls its own deps — install `langchain-community` plus any package the tool needs (e.g. `wikipedia` for `WikipediaAPIWrapper`).
  </Accordion>

  <Accordion title="Disable reflection for tool-heavy agents">
    Set `reflection=False` on agents that call external tools frequently — reflection adds an extra LLM pass per turn.
  </Accordion>

  <Accordion title="One tool per focused agent">
    Split YouTube and Wikipedia into separate agents with dedicated tasks when outputs must stay source-specific.
  </Accordion>

  <Accordion title="Verify API keys before start">
    Export provider keys in the shell or load them with `os.getenv` — LangChain tools fail fast when credentials are missing.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Memory Integration" icon="brain" href="./advanced-memory">
    Learn how to combine LangChain tools with agent memory
  </Card>

  <Card title="Custom Tools" icon="wrench" href="./tools">
    Create your own custom tools for agents
  </Card>
</CardGroup>

<Note>
  For optimal results, ensure all required dependencies are installed and API keys are properly configured for each tool.
</Note>

## Related

<CardGroup cols={2}>
  <Card icon="wrench" href="/features/tools">
    Build and register custom tools for your agents.
  </Card>

  <Card icon="plug" href="/features/mcp">
    Connect agents to external tool servers via Model Context Protocol.
  </Card>
</CardGroup>
