Overview
An on-demand research agent that queries Google, Reddit, and YouTube for a given topic in parallel, combines the results into a unified context, and uses an LLM to generate a structured research brief.
Trigger
On-demand (API call or user input)
Schedule
On-demand per user request
Workflow Steps
Accept research topic
Receive topic string from user input or API request. Optionally accept a research depth parameter (quick: 3 results/platform, deep: 10 results/platform).
Run parallel searches
Simultaneously POST to Scavio search API for Google (informational results), Reddit (community discussion), and YouTube (video coverage). Use asyncio or Promise.all for parallel execution.
Combine and deduplicate results
Merge results from all three platforms into a unified list. Tag each result with its source platform. Remove duplicate URLs.
Format context for LLM
Build a structured prompt context: for each result, include platform tag, title, snippet, and URL. Limit total context to 4,000 tokens.
Generate research brief
Pass context to LLM with instructions to produce a structured brief: summary, key findings, platform-specific insights, and source citations.
Return structured output
Return the research brief as structured JSON with summary (string), key_findings (list), sources (list with URL and platform), and gaps (questions not answered by the search results).
Python Implementation
import asyncio
import aiohttp
import openai
from typing import NamedTuple
SCRAVIO_KEY = "YOUR_API_KEY"
OPENAI_KEY = "YOUR_OPENAI_KEY"
client = openai.OpenAI(api_key=OPENAI_KEY)
PLATFORMS = [
{"platform": "google", "num": 5},
{"platform": "reddit", "num": 5},
{"platform": "youtube", "num": 5},
]
async def search_platform(session: aiohttp.ClientSession, query: str, platform: str, num: int) -> list:
async with session.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": SCRAVIO_KEY},
json={"query": query, "platform": platform, "num": num}
) as resp:
data = await resp.json()
results = data.get("results", [])
for r in results:
r["_platform"] = platform
return results
async def multi_search(topic: str) -> list:
async with aiohttp.ClientSession() as session:
tasks = [search_platform(session, topic, p["platform"], p["num"]) for p in PLATFORMS]
results_by_platform = await asyncio.gather(*tasks)
all_results = []
seen_urls = set()
for platform_results in results_by_platform:
for r in platform_results:
url = r.get("url", "")
if url not in seen_urls:
seen_urls.add(url)
all_results.append(r)
return all_results
def build_context(results: list, max_tokens: int = 3500) -> str:
lines = []
char_budget = max_tokens * 4
for r in results:
line = f"[{r['_platform'].upper()}] {r.get('title', '')}\n{r.get('snippet', '')}\nURL: {r.get('url', '')}\n"
if len("\n".join(lines)) + len(line) > char_budget:
break
lines.append(line)
return "\n".join(lines)
def generate_brief(topic: str, context: str) -> dict:
prompt = f"""Research topic: {topic}
Search results from Google, Reddit, and YouTube:
{context}
Generate a structured research brief with:
1. A 2-3 sentence summary
2. 5 key findings (bullet points)
3. Platform-specific insights (what Reddit says vs YouTube vs Google)
4. 2-3 unanswered questions not covered by these results
Cite sources by URL where relevant."""
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
temperature=0.3
)
return {"brief": response.choices[0].message.content, "sources": [{"url": r.get("url"), "platform": r["_platform"]} for r in []]}
async def run(topic: str):
results = await multi_search(topic)
context = build_context(results)
brief = generate_brief(topic, context)
print(brief["brief"])
return brief
if __name__ == "__main__":
asyncio.run(run("search api for ai agents 2026"))
JavaScript Implementation
const fetch = require('node-fetch');
const OpenAI = require('openai');
const SCRAVIO_KEY = 'YOUR_API_KEY';
const client = new OpenAI({ apiKey: 'YOUR_OPENAI_KEY' });
const PLATFORMS = ['google', 'reddit', 'youtube'];
async function searchPlatform(query, platform) {
const res = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'x-api-key': SCRAVIO_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ query, platform, num: 5 })
});
const data = await res.json();
return (data.results || []).map(r => ({ ...r, _platform: platform }));
}
async function multiSearch(topic) {
const results = await Promise.all(PLATFORMS.map(p => searchPlatform(topic, p)));
const seen = new Set();
return results.flat().filter(r => { if (seen.has(r.url)) return false; seen.add(r.url); return true; });
}
function buildContext(results, maxChars = 14000) {
let ctx = '';
for (const r of results) {
const line = `[${r._platform.toUpperCase()}] ${r.title}\n${r.snippet}\nURL: ${r.url}\n\n`;
if (ctx.length + line.length > maxChars) break;
ctx += line;
}
return ctx;
}
async function run(topic) {
const results = await multiSearch(topic);
const context = buildContext(results);
const completion = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: `Research: ${topic}\n\n${context}\n\nGenerate: summary, key findings, platform insights, unanswered questions.` }],
temperature: 0.3
});
console.log(completion.choices[0].message.content);
}
run('search api for ai agents 2026').catch(console.error);
Platforms Used
Web search with knowledge graph, PAA, and AI overviews
Community, posts & threaded comments from any subreddit
YouTube
Video search with transcripts and metadata