ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Add Structured Search to an AI Assistant
Tutorial

How to Add Structured Search to an AI Assistant

Stop pasting raw HTML into your prompt. Add a typed search call to your AI assistant in 5 minutes with Scavio.

Get Free API KeyAPI Docs

An r/n8n thread asked for a search API that returns structured snippets ready to drop into an LLM context window — not raw HTML, not stripped meaning. This tutorial wires Scavio's /search endpoint into a Python or Node assistant in under 5 minutes.

Prerequisites

  • Python 3.10+ or Node 20+
  • Scavio API key (250 free credits/mo)

Walkthrough

Step 1: Get your API key

Sign up at scavio.dev. The free tier returns 250 credits/mo, no card.

Bash
export SCAVIO_API_KEY=sk_...

Step 2: Make the search call

POST to /api/v1/search with x-api-key header.

Python
import os, requests
API_KEY = os.environ['SCAVIO_API_KEY']

def search(query):
    r = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY},
        json={'query': query})
    return r.json()

Step 3: Pull only the fields the LLM needs

Title, snippet, link. Drop the rest.

Python
def trim(results):
    return [{'title': r['title'], 'snippet': r['snippet'], 'url': r['link']}
            for r in results.get('organic_results', [])[:5]]

Step 4: Inject into the prompt

Pass trimmed results as part of the system context.

Python
context = '\n'.join(f'- {r["title"]}: {r["snippet"]} ({r["url"]})' for r in trim(search('reddit api alternatives 2026')))
prompt = f'Use this context to answer the question.\n\n{context}\n\nQuestion: which APIs replace Reddit\'s direct search?'

Step 5: Pair with the extract endpoint when more context is needed

Fetch the top result as markdown.

Python
def fetch(url):
    r = requests.post('https://api.scavio.dev/api/v1/extract',
        headers={'x-api-key': API_KEY}, json={'url': url, 'format': 'markdown'})
    return r.json().get('markdown', '')

Python Example

Python
import os, requests
API_KEY = os.environ['SCAVIO_API_KEY']

def ask_with_search(question):
    s = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': API_KEY}, json={'query': question}).json()
    ctx = '\n'.join(f'{r["title"]}: {r["snippet"]}' for r in s.get('organic_results', [])[:5])
    return ctx

print(ask_with_search('what is mcp'))

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;
export async function search(q) {
  const r = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ query: q })
  });
  return r.json();
}

Expected Output

JSON
Five clean snippets per query, ready to inject into the LLM's context. Token cost stays under 800 tokens for the search context block.

Related Tutorials

  • How to Replace Google Custom Search API with Scavio
  • How to Build a Research Assistant Without Token Overflow
  • How to Replace the Bing Web Search API for a Deep Research Agent

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.10+ or Node 20+. Scavio API key (250 free credits/mo). A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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.

Related Resources

Use Case

n8n Search Enrichment Workflow

Read more
Best Of

Best n8n Search API Nodes Comparison (May 2026)

Read more
Best Of

Best n8n Search API Integrations in 2026

Read more
Use Case

Local LLM Search Grounding via API

Read more
Solution

Migrate from Brave Search API to Scavio for Better Coverage

Read more
Workflow

n8n MCP Search Automation

Read more

Start Building

Stop pasting raw HTML into your prompt. Add a typed search call to your AI assistant in 5 minutes with Scavio.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy