Feeding Reddit Discussions into LLMs: A Market Research Summarizer

Customer research usually starts with a question like "what do project managers hate about their tools?" Reddit has thousands of unprompted answers, but they sit in long threads written in a hurry. Reading 50 of them is an afternoon. Pasting them into a chat window works once, then you have to do it again next month.

This guide builds a small pipeline in Python. It pulls the busiest threads from the subreddits you choose, compresses each one into a short digest, and sends the digests to an LLM with instructions to return structured JSON: pain points, requested features, and tools people mention. The Reddit side uses the SteadyAPI Reddit API. The LLM side works with any chat completions endpoint that follows the OpenAI format.

Prerequisites

  • A SteadyAPI API key from steadyapi.com. One run of the script costs 8 requests.
  • Python 3.8+ with requests.
  • For the final step, an API key and model name for an OpenAI-compatible endpoint. The data collection and the prompt work without one, thanks to a --dry-run flag.

Choose the threads, not the whole subreddit

An LLM has a limited context window and you pay for every token you send, so what you feed it matters more than how much. The script makes two decisions before the model sees anything:

1. Which threads. It lists the hot posts of each subreddit with GET /v1/reddit/posts (weight 2), keeps posts with at least 15 comments, skips pinned ones, and picks the two busiest. 2. Which comments. It downloads each thread with GET /v1/reddit/post (weight 1). Replies come back nested under their parent in post_comments, each with a score.

Within a thread, the script ranks comments by score and keeps the top ones, up to 5,000 characters per thread. Comments with fewer than 2 points or under 30 characters are dropped. Replies are indented by depth, so the model can see who is answering whom.

Two things to know about the data:

  • You cannot choose the slice. A thread response holds about 40 comments, not the whole discussion. For a thread with 129 comments, the model sees only part of it.
  • Some requests fail once and then work. The API can return "success": false with HTTP 200. The call() helper retries once on that, and collect() skips a thread that still fails instead of stopping the run.

The full script

Save this as reddit_research_summarizer.py. Set the subreddits at the top to the communities your customers use.

import html
import json
import os
import re
import sys
import time

import requests

BASE = "https://api.steadyapi.com"
API = f"{BASE}/v1/reddit"
HEADERS = {"Authorization": f"Bearer {os.environ['STEADYAPI_KEY']}"}

# Any OpenAI-compatible chat completions endpoint works here.
LLM_URL = os.environ.get("LLM_BASE_URL", "https://api.openai.com/v1") + "/chat/completions"
LLM_KEY = os.environ.get("LLM_API_KEY", "")
LLM_MODEL = os.environ.get("LLM_MODEL", "")

SUBREDDITS = ["projectmanagement", "startups"]
THREADS_PER_SUBREDDIT = 2
MIN_COMMENTS = 15
MAX_CHARS_PER_THREAD = 5000


def call(path, **params):
    failures = 0
    for attempt in range(4):
        r = requests.get(f"{API}/{path}", headers=HEADERS, params=params, timeout=90)
        if r.status_code in (429, 500, 502, 503):
            time.sleep(2 ** attempt)
            continue
        r.raise_for_status()
        data = r.json()
        if data.get("success") is False:
            failures += 1
            if failures < 2:
                time.sleep(2)  # some requests fail once and then work, so retry one time
                continue
            raise ValueError(data["message"])
        return data
    raise RuntimeError(f"{path} failed after retries")


def clean(text):
    text = html.unescape(text or "")
    text = re.sub(r"https?://\S+", "", text)
    text = re.sub(r"\\(.)", r"\1", text)  # Reddit markdown escapes such as \- and \_
    return re.sub(r"\s+", " ", text).strip()


def flatten(comments, depth=0):
    for c in comments:
        yield depth, c
        yield from flatten(c["replies"], depth + 1)


def collect():
    """Find busy threads in each subreddit and download them."""
    threads = []
    for sub in SUBREDDITS:
        posts = call("posts", subreddit=sub, sortType="hot")["body"]
        busy = [p for p in posts if (p.get("num_comments") or 0) >= MIN_COMMENTS and not p.get("stickied")]
        busy.sort(key=lambda p: p["num_comments"], reverse=True)
        for post in busy[:THREADS_PER_SUBREDDIT]:
            try:
                data = call("post", url="https://www.reddit.com" + post["permalink"])
            except ValueError:
                continue  # some threads fail; skip them instead of stopping
            threads.append((sub, data["body"]["post"], data["body"]["post_comments"]))
    return threads


def digest(sub, post, comments):
    """Compact text for one thread: the post, then comments ranked by score."""
    lines = [f"THREAD in r/{sub}: {clean(post['title'])}"]
    body = clean(post.get("selftext"))
    if body:
        lines.append(f"POST: {body[:700]}")
    ranked = sorted(flatten(comments), key=lambda dc: -dc[1]["score"])
    used = sum(len(line) for line in lines)
    for depth, c in ranked:
        text = clean(c["content"])
        if c["score"] < 2 or len(text) < 30:
            continue
        line = f"{'  ' * depth}[{c['score']} pts] {text[:400]}"
        if used + len(line) > MAX_CHARS_PER_THREAD:
            break
        lines.append(line)
        used += len(line)
    return "\n".join(lines)


def build_prompt(digests):
    rules = (
        "You are a market research analyst. Use ONLY the Reddit discussions below. "
        "Return JSON with these keys: pain_points (a list of objects with theme, "
        "evidence, and mentions), requested_features (a list of strings), "
        "tools_mentioned (a list of strings), and caveats (a string). "
        "Copy evidence word for word from a comment. If the text does not support "
        "an answer, say so in caveats instead of guessing."
    )
    return rules + "\n\n" + "\n\n---\n\n".join(digests)


def ask_llm(prompt):
    r = requests.post(
        LLM_URL,
        headers={"Authorization": f"Bearer {LLM_KEY}"},
        json={
            "model": LLM_MODEL,
            "temperature": 0,
            "response_format": {"type": "json_object"},
            "messages": [{"role": "user", "content": prompt}],
        },
        timeout=120,
    )
    r.raise_for_status()
    return json.loads(r.json()["choices"][0]["message"]["content"])


if __name__ == "__main__":
    threads = collect()
    digests = [digest(*t) for t in threads]
    prompt = build_prompt(digests)
    print(f"{len(threads)} threads, {len(prompt):,} characters in the prompt", file=sys.stderr)
    if "--dry-run" in sys.argv:
        print(prompt)
    else:
        print(json.dumps(ask_llm(prompt), indent=2))

Run it with the dry run first:

export STEADYAPI_KEY="your_api_key"
python reddit_research_summarizer.py --dry-run

Then run it for real:

export LLM_BASE_URL="https://api.openai.com/v1"   # or any compatible endpoint
export LLM_API_KEY="your_llm_key"
export LLM_MODEL="the-model-you-use"
python reddit_research_summarizer.py > findings.json

What the model actually receives

I ran the dry run against two communities. The first line goes to stderr, and the prompt follows:

4 threads, 16,177 characters in the prompt
...
THREAD in r/projectmanagement: New Project Manager struggling with accountability and stress. Is this just part of the job?
[19 pts] Yes, this is a common shock for people moving into PM. You own the outcome without controlling the work...
...
THREAD in r/startups: How do you evaluate a startup or app idea before building it? (i will not promote)
[6 pts] What finally fixed this for me was asking about the past instead of the idea: "when did this last happen to you...

Four threads fit in about 16,000 characters, which is roughly 4,000 tokens by the usual rule of thumb. That is small enough for any current model, and it leaves room for a larger run with more subreddits.

I tested the Reddit side against live data. I tested the LLM call only against a local mock server that follows the chat completions format. It confirmed that the request goes to /chat/completions with the model name, temperature 0 and a JSON response format. I have not shown a model's answer here, because I did not run one. Your output will depend on the model you choose.


Why the prompt looks the way it does

Each instruction in build_prompt() is there to prevent a specific failure:

  • "Use ONLY the Reddit discussions below" keeps the model from filling gaps with its general knowledge of the topic.
  • "Copy evidence word for word from a comment" gives you quotes you can search for in the original thread. If a quote does not appear in the digest, the model made it up.
  • "Say so in caveats instead of guessing" gives it a place to admit that four threads is a small sample.
  • temperature 0 and a JSON response format make runs comparable and let you load the output with json.loads.

Comment scores help here too. The digest puts each comment's points in front of it, so the model can weigh a 19-point comment above a 2-point one. Treat mentions in the output as a rough count in a handful of threads, not as a survey result.


Best practices

  • Check the quotes. Write a few lines that test whether each evidence string appears in the digest. Drop the ones that do not.
  • Keep the raw digests. Save the prompt next to the output with the date. Reddit scores and comments change, and you will want to explain a result later.
  • Sample more than one day. The hot list changes daily. Run the script weekly for a month and compare, instead of trusting one snapshot.
  • Split big runs. If you add more subreddits, send one subreddit per LLM call and merge the results. Smaller prompts are cheaper and easier to debug.
  • Do not name people. The digest keeps comment text but not usernames. Keep it that way if you share the output.

Cost

One run of this script costs 8 requests: 2 listing calls at weight 2, plus 4 threads at 1 each. Adding a subreddit adds 4 requests. Responses are cached for about 15 minutes, so a repeated run inside that window returns the same data. The Free plan's 500 requests a month covers about 60 runs of this size, and the Starter plan ($14.99/mo, 10,000 requests) covers about 1,250. The standard rate limit is 10 requests per second per account, and only HTTP 200 responses count toward your quota. The LLM call is billed by your model provider.


Bonus: ask the question directly

If you use Claude Code, Cursor, VS Code, or any MCP client, you can connect it to https://api.steadyapi.com/mcp with your API key. Then you can ask what people in a subreddit complain about in plain English, before you write the pipeline.


Conclusion

You picked the busiest threads in each community, trimmed them to the highest-scoring comments, and built a prompt that asks an LLM for structured findings with word-for-word evidence. The same pipeline handles any topic: change the subreddits and the wording of the instructions.

Create a free account at steadyapi.com (no card required) and run the dry run on the communities your customers use. The API documentation lists every Reddit parameter with ready-made examples in cURL, JavaScript, PHP, and Python.