Hermes agents rely on headless browsers or SearXNG for web search, which are slow, fragile, and resource-heavy. This tutorial replaces browser-based search with a direct API call. The agent gets structured results in 300ms instead of 3-5 seconds, with no Puppeteer, no Chrome, and no Docker dependency. Each search costs $0.005.
Prerequisites
- Python 3.8+
- requests library
- A Scavio API key from scavio.dev
- Hermes agent framework installed
Walkthrough
Step 1: Create the browser-free search tool
Build a search function that returns structured results without any browser dependency.
import os, requests, json
API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
def web_search(query, num_results=5):
"""Browser-free web search for Hermes agents.
Returns structured results in ~300ms vs 3-5s with headless Chrome.
"""
resp = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}, timeout=10)
resp.raise_for_status()
data = resp.json()
results = []
for r in data.get('organic_results', [])[:num_results]:
results.append({
'title': r.get('title', ''),
'url': r.get('link', ''),
'content': r.get('snippet', ''),
})
# Include People Also Ask for richer context
paa = [q.get('question', '') for q in data.get('people_also_ask', [])[:3]]
return {'results': results, 'related': paa, 'count': len(results)}
# Test - no browser needed
result = web_search('python async database tutorial 2026')
print(f'Results: {result["count"]} (no browser, no Chrome, no Docker)')
for r in result['results'][:3]:
print(f' {r["title"][:50]}')
print(f' {r["url"]}')
if result['related']:
print(f'\nRelated questions:')
for q in result['related']:
print(f' - {q}')
print(f'\nCost: $0.005/search')Step 2: Register as a Hermes tool
Wrap the search function as a tool that Hermes can discover and invoke.
HERMES_SEARCH_TOOL = {
'type': 'function',
'function': {
'name': 'web_search',
'description': 'Search the web for current information. Use when you need to find documentation, verify facts, check APIs, or answer questions requiring up-to-date data. No browser required.',
'parameters': {
'type': 'object',
'properties': {
'query': {
'type': 'string',
'description': 'The search query. Be specific for better results.'
},
'num_results': {
'type': 'integer',
'description': 'Number of results to return (1-10, default 5)',
'default': 5
}
},
'required': ['query']
}
}
}
def handle_hermes_tool(name, args):
"""Handle tool calls from Hermes agent."""
if name == 'web_search':
query = args.get('query', '')
num = args.get('num_results', 5)
result = web_search(query, num)
return json.dumps(result)
return json.dumps({'error': f'Unknown tool: {name}'})
# Simulate Hermes calling the tool
print('Hermes tool registered: web_search')
print('Dependencies removed: puppeteer, chromium, selenium')
result = handle_hermes_tool('web_search', {'query': 'FastAPI deployment best practices'})
parsed = json.loads(result)
print(f'\nTool returned {parsed["count"]} results')Step 3: Replace browser search in the Hermes config
Update the Hermes agent configuration to use API search instead of browser search.
# BEFORE: Hermes with browser search (in hermes_config.py)
# search_tool = BrowserSearchTool()
# Requires: puppeteer, chromium, 500MB+ disk, 3-5s per search
# AFTER: Hermes with API search
# search_tool = web_search # The function we built above
# Requires: requests library only, 300ms per search
def demo_hermes_agent():
"""Demonstrate Hermes agent using API search instead of browser."""
print('Hermes Agent Starting...')
print(' Search backend: Scavio API (no browser)')
print(' Dependencies: requests only')
print(' Avg latency: ~300ms')
# Agent task: research a topic
task = 'Find the best Python web framework for async APIs in 2026'
print(f'\nTask: {task}')
# Step 1: Search
print('\n Step 1: Searching...')
result = web_search(task)
print(f' Found {result["count"]} results in ~300ms')
# Step 2: Process results
print('\n Step 2: Processing top results...')
for r in result['results'][:3]:
print(f' - {r["title"][:50]}')
# Step 3: Follow-up search
if result['related']:
print(f'\n Step 3: Follow-up search...')
followup = web_search(result['related'][0])
print(f' Follow-up: {followup["count"]} more results')
print(f'\n Total cost: $0.010 (2 searches)')
print(f' Browser equivalent: 6-10 seconds, 500MB RAM')
print(f' API equivalent: 600ms, 0MB extra RAM')
demo_hermes_agent()Python Example
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def hermes_search(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}, timeout=10).json()
return [{'title': r['title'], 'url': r['link']} for r in data.get('organic_results', [])[:5]]
for r in hermes_search('python async database'):
print(f'{r["title"][:50]}')
print('No browser. $0.005/search.')JavaScript Example
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH,
body: JSON.stringify({ query: 'python async database', country_code: 'us' })
}).then(r => r.json());
(data.organic_results || []).slice(0, 5).forEach(r => console.log(r.title));
console.log('No browser needed.');Expected Output
Results: 5 (no browser, no Chrome, no Docker)
FastAPI with Async SQLAlchemy - Complete Guide
https://fastapi.tiangolo.com/advanced/async-sql/
Python Async Database Tutorial 2026 - Real Python
https://realpython.com/async-database-python/
Hermes Agent Starting...
Search backend: Scavio API (no browser)
Dependencies: requests only
Avg latency: ~300ms
Task: Find the best Python web framework for async APIs in 2026
Total cost: $0.010 (2 searches)
Browser equivalent: 6-10 seconds, 500MB RAM
API equivalent: 600ms, 0MB extra RAM