π³ Cookbook: Agentic Search Engine¶
Build an AI-powered search assistant that combines web search, scraping, and LLM summarization into a single intelligent API.
π― What You'll Build¶
A service that: 1. Searches the web (Brave, Google, Bing) 2. Scrapes relevant pages for full content 3. Uses AI to summarize findings with citations
ποΈ Phase 1: Clone & Setup¶
1. Get the Code¶
2. Install Dependencies¶
3. Configure Environment¶
Key Variables:
# LLM Configuration
LLM_MODEL=openai/gpt-oss-20b
LLM_SUMMARY_MODEL=llama-3.3-70b-versatile
TRAYLINX_BASE_URL=https://switchai.traylinx.com/v1
# Search Providers (get free keys)
BRAVE_API_KEY=your-brave-key
# Optional: GOOGLE_API_KEY, BING_API_KEY
π Phase 2: Run the Service¶
π§ͺ Phase 3: Test the Flows¶
Flow 1: Full Agentic Search¶
The complete orchestration: search β scrape β AI summarize.
curl -X POST http://localhost:8000/v1/search \
-H "Content-Type: application/json" \
-d '{
"query": "What are the latest trends in AI agents?",
"flow": "agentic",
"params": {
"use_search": true,
"providers": ["brave"]
}
}'
Response:
{
"answer": "Based on my research, the latest trends in AI agents include...",
"sources": [
{"title": "...", "url": "https://..."},
{"title": "...", "url": "https://..."}
]
}
Flow 2: Search Only¶
Just get raw search results without AI processing.
curl -X POST http://localhost:8000/v1/search \
-H "Content-Type: application/json" \
-d '{
"query": "Python async best practices",
"flow": "search_only"
}'
Flow 3: Scrape Only¶
Extract content from a specific URL.
curl -X POST http://localhost:8000/v1/search \
-H "Content-Type: application/json" \
-d '{
"query": "extract main content",
"flow": "scrap_only",
"params": {
"urls": ["https://example.com/article"]
}
}'
π€ Phase 4: OpenAI-Compatible Chat¶
Use it like a drop-in replacement for ChatGPTβwith live web access!
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "agentic-search",
"messages": [
{"role": "user", "content": "What is the weather in Tokyo right now?"}
]
}'
The service automatically detects intent: - "Show me videos about X" β Video search - "Extract text from URL" β Web scraping - General questions β Search + Summarize
π Phase 5: Enable A2A Authentication¶
To let other agents call your search service, add Sentinel auth.
1. Get Agent Credentials¶
From console.traylinx.com:
- TRAYLINX_CLIENT_ID
- TRAYLINX_CLIENT_SECRET
2. Add to .env¶
TRAYLINX_CLIENT_ID=ag-xxx
TRAYLINX_CLIENT_SECRET=ts-xxx
AUTH_SERVICE_URL=https://sentinel.traylinx.com/validate
3. Call as an Agent¶
curl -X POST http://localhost:8000/v1/search \
-H "X-Agent-Secret-Token: your-token" \
-H "X-Agent-User-Id: your-agent-id" \
-H "Content-Type: application/json" \
-d '{"query": "AI news", "flow": "agentic"}'
ποΈ Architecture Overview¶
Request
β
βΌ
βββββββββββββββββ
β Intent Router β β Detects: search/scrape/video/news
βββββββββ¬ββββββββ
β
βββββββββ΄ββββββββ
βΌ βΌ
βββββββββββ βββββββββββββ
β Search β β Scraper β
β Agent β β Agent β
ββββββ¬βββββ βββββββ¬ββββββ
β β
ββββββββ¬ββββββββ
βΌ
βββββββββββββββ
β LLM Summary β β Generates cited answer
βββββββββββββββ
π Next Steps¶
- Deploy to production with Docker
- Add Redis caching for faster repeated queries
- Integrate with your own agent via A2A tools