Giving Your LLM Agent Web Search Without Burning Money: Self-hosted SearXNG, Caching and Citation Checks
说明与用途
一种自动化方案,使用自托管的 SearXNG、磁盘缓存和速率限制,使 LLM 代理能够在不付费的情况下执行网络搜索。
问题
LLM agents repeatedly query paid web‑search APIs, causing high costs, rate limits, and unreliable citations.
结果
The gateway reduced API costs to zero, limited queries to 20 per minute, cached results for 6 hours, and prevented agents from repeating identical searches.
工作流
- Deploy SearXNG in Docker with JSON output enabled
- Configure SearXNG to bind to 127.0.0.1 and disable public limiter
- Implement a Python gateway using httpx and diskcache
- Add a TokenBucket class to enforce a 20 queries/minute limit
- Hash and normalize queries to cache results for 6 hours
- Return cached results when available, otherwise fetch from SearXNG
- Parse JSON results and forward to LLM agent
证据
Agents called external search APIs directly, without caching or rate limiting, resulting in duplicate queries and high costs.
Deploy SearXNG in Docker with JSON output enabled
Implement a Python gateway using httpx and diskcache
- 记录日期: 2026-10-06T00:40:51.071Z