I spend too much time on Reddit. Naturally, I wanted my AI agents to join me there. The official Reddit API is notoriously difficult to access now. It requires API keys, has strict rate limits, and costs money for heavy usage. I wanted a way for my local AI to "surf" Reddit just like I do: by reading the public pages. I built a tool for Open WebUI that allows agents to browse, search, and read Reddit through **Redlib**, a private, open-source frontend. No API keys required. > [!NOTE] Get the Tool > Download the **Redlib Reddit Client** for Open WebUI here: [openwebui.com/t/whogben/reddit_via_redlib](https://openwebui.com/t/whogben/reddit_via_redlib) ## The Context To give an AI access to Reddit without the official API, you have to parse HTML. But Reddit's main site is heavy, laden with JavaScript, and hostile to scrapers. **Redlib** (formerly Libreddit) solves this. It is an alternative frontend that renders Reddit content as lightweight, static HTML. It is designed for privacy and speed, which accidentally makes it perfect for AI agents. Because Redlib instances are just standard web servers returning predictable HTML, we can treat them like an API. If I can read a thread in my browser, my agent can read it via an HTTP request. ## The Solution I built a Python tool that acts as a browser-in-a-box for Open WebUI. It bridges the gap between the LLM's desire for information and Redlib's HTML structure. The core of the project is the `RedlibAPI` class. It uses `httpx` to fetch pages and `BeautifulSoup` to make sense of them. ### Browsing and Searching The `list_posts` function mimics the experience of scrolling a feed. It handles: - **Subreddits**: Fetching "hot", "new", or "top" posts from specific communities. - **Search**: Querying Reddit globally or within a subreddit. - **Pagination**: Redlib uses opaque cursors for pagination. The tool manages these automatically, letting the agent request "page 2" without knowing how the URL parameters work. ### Reading Content The `read_posts` function is the heavy lifter. When the agent selects a post, this function extracts: - The main text or external link. - The vote score and comment count. - **Images**: If the post contains an image, the tool can optionally send it to a Vision LLM (like Gemini Flash) to generate a description. This lets a text-only model "see" the memes. ### Deep Dives The `get_comments` function fetches nested conversation threads. This allows the agent to do more than just read headlines; it can analyze community sentiment, summarize debates, or find specific answers buried in the replies. ## Example Usage Here is how the agent uses the tool in practice. ### 1. The Daily Catch-up **Prompt:** "What are the top 3 posts on r/LocalLLaMA right now? Summarize them." **Tool Call:** ```python list_posts(subreddit="LocalLLaMA", limit=3, sort="hot") ``` **Response:** The agent receives a JSON list of posts and summarizes the current trends in local AI models. ### 2. The Investigation **Prompt:** "Search for 'Open WebUI' on Reddit and tell me what features people are requesting." **Tool Call:** ```python list_posts(query="Open WebUI", sort="relevance", time_filter="month") ``` **Response:** The agent finds recent discussion threads, reads them, and synthesizes a list of user requests. ### 3. The Background Check **Prompt:** "Who is this u/spez guy?" **Tool Call:** ```python get_user(username="spez", include_posts=True) ``` **Response:** The agent pulls the user's profile, karma stats, and recent post history to explain who they are. ## Why This Matters This tool turns Reddit into a read-only knowledge base for your AI. It is particularly useful for getting real-time human opinions on niche topics that might not be in the model's training data. You can use any public Redlib instance, but I recommend self-hosting one for better performance and privacy. The tool supports custom URLs via the "Valves" configuration. Now my AI can doomscroll just as efficiently as I do.