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

# Reddit PraisonAI Integration

> Guide for integrating Reddit search capabilities with PraisonAI agents, including API setup and configuration

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

agent = Agent(
    name="Reddit Researcher",
    instructions="Search Reddit for community discussions.",
    tools=[reddit_search],
)
agent.start("What are people saying about PraisonAI on Reddit this week?")
```

The user asks about community sentiment; the agent searches Reddit and summarises top threads.

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

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

    class A agent
    class U,O tool
    class T tool
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Reddit PraisonAI Integration

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

# Reddit PraisonAI Integration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export REDDIT_USER_AGENT=[USER]
export REDDIT_CLIENT_SECRET=xxxxxx
export REDDIT_CLIENT_ID=xxxxxx
```

\[USER] in this format script:APP:v1.0(by/u/USERNAME)

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install praisonai langchain_community praw
```

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

## Quick Start

<Steps>
  <Step title="Install">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents praw
    export REDDIT_CLIENT_ID=your_client_id
    export REDDIT_CLIENT_SECRET=your_client_secret
    ```
  </Step>

  <Step title="Search Reddit with agent">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="RedditAgent",
        instructions="Search Reddit for relevant discussions and insights.",
    )

    agent.start("Find the top discussions about Python in the last week")
    ```
  </Step>
</Steps>

## Code

### Single Agent

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from langchain_community.tools.reddit_search.tool import RedditSearchRun

agent = Agent(name="RedditSearchAgent",instructions="Search Reddit for information", tools=[RedditSearchRun],)

agent.start("Search Reddit for information about the latest AI advancements in subreddit all")
```

### Multi Agents

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from langchain_community.tools.reddit_search.tool import RedditSearchRun

agent = Agent(name="RedditSearchAgent",instructions="Search Reddit for information", tools=[RedditSearchRun],)

task = Task(description="Search Reddit for information about the latest AI news in subreddit all", agent=agent)

agents = AgentTeam(agents=[agent],tasks=[task])

agents.start()
```

## No Code

tools.py

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from langchain_community.tools.reddit_search.tool import RedditSearchRun
```

agents.yaml

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: crewai
topic: research about the causes of lung disease
agents:  # Canonical: use 'agents' instead of 'roles'
  research_analyst:
    instructions:  # Canonical: use 'instructions' instead of 'backstory' Experienced in analyzing scientific data related to respiratory health.
    goal: Analyze data on lung diseases
    role: Research Analyst
    tasks:
      data_analysis:
        description: Gather and analyze data on the causes and risk factors of lung
          diseases.
        expected_output: Report detailing key findings on lung disease causes.
    tools:
    - 'RedditSearchRun'
```

## Best Practices

<AccordionGroup>
  <Accordion title="Use read-only scopes for research">
    When only reading Reddit content, use read-only OAuth scopes to limit permissions.
  </Accordion>

  <Accordion title="Respect rate limits">
    Reddit has rate limits - add delays between requests when processing many posts.
  </Accordion>

  <Accordion title="Filter by subreddit">
    Specify target subreddits in agent instructions for more relevant, focused results.
  </Accordion>

  <Accordion title="Check content age">
    Reddit results can be years old - filter by `created_utc` when you need recent information.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
