Skip to main content

Prerequisites

  1. Create/Login to Reddit account
  2. Create a Reddit App
  3. Get credentials
    • client_id: Found under your app name (looks like a random string)
    • client_secret: Listed as “secret”
    • user_agent: Format as: “platform:app_id:version (by /u/username)”
    • username: Your Reddit username
    • password: Your Reddit account password

from agno.agent import Agent
from agno.tools.reddit import RedditTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    instructions=[
        "Use your tools to answer questions about Reddit content and statistics",
        "Respect Reddit's content policies and NSFW restrictions",
        "When analyzing subreddits, provide relevant statistics and trends",
    ],
    tools=[RedditTools()],
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What are the top 5 posts on r/SAAS this week ?", stream=True)

Run the Example

# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools

# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate

python reddit_tools.py
For details, see Reddit cookbook.