Tutorial

How to Build Streamlit Research UI with Agents

Build a Streamlit app that runs research agents with live search. Interactive UI for multi-source research at $0.005/query.

Streamlit makes it easy to build interactive research UIs that non-technical teammates can use. This tutorial builds a research app where users type a topic, the app runs search agents across multiple platforms, and displays organized results with sentiment and source quality scores. Each research query costs $0.015-0.025.

Prerequisites

  • Python 3.8+
  • streamlit and requests installed
  • A Scavio API key from scavio.dev
  • Basic Streamlit knowledge

Walkthrough

Step 1: Build the research backend

Create search functions that the Streamlit app will call.

Python
import os, requests, json
from datetime import datetime

API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

def research(topic, platforms=None):
    """Run multi-platform research on a topic."""
    if platforms is None:
        platforms = [None, 'reddit', 'youtube']
    all_results = []
    for platform in platforms:
        body = {'query': topic, 'country_code': 'us'}
        if platform:
            body['platform'] = platform
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers=SH, json=body).json()
        for r in data.get('organic_results', [])[:5]:
            all_results.append({
                'title': r.get('title', ''),
                'link': r.get('link', ''),
                'snippet': r.get('snippet', ''),
                'platform': platform or 'google',
                'position': r.get('position', 0)
            })
    return all_results

# Test the backend
results = research('ai agent frameworks 2026')
print(f'Research returned {len(results)} results across {len(set(r["platform"] for r in results))} platforms')
for r in results[:3]:
    print(f'  [{r["platform"]}] {r["title"][:50]}')

Step 2: Create the Streamlit app

Build the interactive research UI with search input and results display.

Python
# streamlit_research.py
# Run with: streamlit run streamlit_research.py

# Note: This is the Streamlit app code. Testing the logic here without Streamlit.

def format_results_for_display(results):
    """Format results as the Streamlit app would display them."""
    by_platform = {}
    for r in results:
        p = r['platform']
        if p not in by_platform:
            by_platform[p] = []
        by_platform[p].append(r)
    output = []
    for platform, items in by_platform.items():
        output.append(f'\n## {platform.upper()} ({len(items)} results)')
        for item in items:
            output.append(f'  - [{item["title"][:50]}]({item["link"]})')
            output.append(f'    {item["snippet"][:80]}')
    return '\n'.join(output)

# Simulate Streamlit workflow
topic = 'best search api for ai agents'
results = research(topic)
formatted = format_results_for_display(results)
print(f'=== Research Results: "{topic}" ===')
print(formatted)
print(f'\nCost: ${len(set(r["platform"] for r in results)) * 0.005:.3f}')

Step 3: Add source quality scoring

Score results by domain authority and recency for better research quality.

Python
TRUSTED_DOMAINS = ['github.com', 'stackoverflow.com', 'docs.python.org', 'arxiv.org',
                   'developer.mozilla.org', 'aws.amazon.com', 'cloud.google.com']
FORUM_DOMAINS = ['reddit.com', 'news.ycombinator.com', 'dev.to']

def score_source(result):
    link = result.get('link', '')
    score = 50  # base score
    for d in TRUSTED_DOMAINS:
        if d in link:
            score += 30
            break
    for d in FORUM_DOMAINS:
        if d in link:
            score += 10
            break
    if '2026' in result.get('title', '') or '2026' in result.get('snippet', ''):
        score += 15
    if result.get('position', 99) <= 3:
        score += 10
    return min(score, 100)

def research_with_scores(topic):
    results = research(topic)
    for r in results:
        r['quality_score'] = score_source(r)
    results.sort(key=lambda x: x['quality_score'], reverse=True)
    print(f'\n=== Scored Research: "{topic}" ===')
    for r in results[:8]:
        print(f'  [{r["quality_score"]:3}] [{r["platform"]:7}] {r["title"][:45]}')
    avg = sum(r['quality_score'] for r in results) / len(results) if results else 0
    print(f'\n  Avg quality: {avg:.0f}/100 | Sources: {len(results)}')

research_with_scores('python web framework comparison 2026')

Python Example

Python
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def quick_research(topic):
    for platform in [None, 'reddit']:
        body = {'query': topic, 'country_code': 'us'}
        if platform: body['platform'] = platform
        data = requests.post('https://api.scavio.dev/api/v1/search', headers=SH, json=body).json()
        label = platform or 'google'
        print(f'[{label}] {len(data.get("organic_results", []))} results')

quick_research('ai agent frameworks 2026')
print('Cost: $0.010')

JavaScript Example

JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
async function research(topic) {
  for (const p of [null, 'reddit']) {
    const body = { query: topic, country_code: 'us', ...(p && { platform: p }) };
    const data = await fetch('https://api.scavio.dev/api/v1/search', {
      method: 'POST', headers: SH, body: JSON.stringify(body)
    }).then(r => r.json());
    console.log(`[${p || 'google'}] ${(data.organic_results || []).length} results`);
  }
}
await research('ai agent frameworks 2026');

Expected Output

JSON
Research returned 15 results across 3 platforms
  [google] Top AI Agent Frameworks 2026: Complete Guide
  [google] LangChain vs CrewAI vs Autogen Comparison
  [reddit] Best framework for building AI agents?

=== Scored Research: "python web framework comparison 2026" ===
  [ 90] [google ] Python Web Frameworks 2026 - Real Python
  [ 80] [google ] FastAPI vs Django vs Flask Performance 2026
  [ 75] [reddit ] What framework are you using in 2026?
  [ 65] [youtube] Python Framework Comparison Tutorial

  Avg quality: 68/100 | Sources: 15

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.8+. streamlit and requests installed. A Scavio API key from scavio.dev. Basic Streamlit knowledge. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Build a Streamlit app that runs research agents with live search. Interactive UI for multi-source research at $0.005/query.