Giving Your LLM Agent Web Search Without Burning Money: Self-hosted SearXNG, Caching and Citation Checks
Описание и применение
Автоматизированный рецепт, позволяющий LLM‑агенту выполнять веб‑поиск без оплаты, используя самодостаточный SearXNG, кэширование и ограничение запросов.
Задача
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