---
source_url: "https://note.com/hacklog_stealth/n/n5c53268b546d?hl=en"
title: "How to make AI agent search API costs zero | Just run SearXNG with Docker｜Hack-Log"
mirrored_at: 2026-08-30T13:03:00.584Z
host: note.com
cited_in_42a: true
mirror_canonical: "https://index.42a.ai/note.com/hacklog_stealth/n/n5c53268b546d__q__hl_en"
---

> **Original source:** https://note.com/hacklog_stealth/n/n5c53268b546d?hl=en

Every time you ask an AI agent to "look something up," are search API charges piling up in the background?

Brave Search API, Tavily, Perplexity, and others are convenient search features for agents, but they cost money the more you use them. If you search thousands of times a month, the API costs alone can reach several thousand to tens of thousands of yen.

In this article, I will introduce a way to make search API costs zero. We will use an open-source meta-search engine called "SearXNG." It runs with a single Docker command.

## What is SearXNG?

SearXNG is a meta-search engine that aggregates and returns results from over 70 search engines, including Google, Bing, and DuckDuckGo.

Summary of features:

-   Completely free (GNU AGPL-3.0 license)
    
-   No API key required, no query limits
    
-   Built-in JSON API allows direct calls from agents
    
-   Self-hosted, so search data is not leaked externally
    

## Setup steps

### 1\. Start with Docker

```
docker run -d --name searxng \
  -p 8888:8080 \
  -e SEARXNG_BASE_URL=http://localhost:8888 \
  searxng/searxng:latest
```

With just this, a search engine will launch at \`http://localhost:8888\`.

### 2\. Search via JSON API

While you can use it from a browser, to use it from an AI agent, you call the JSON API.

```
curl "http://localhost:8888/search?q=Claude+Code&format=json"
```

This returns search results in JSON format. You can use it just like a paid API.

### 3\. Connect from OpenClaw or Claude Code

For OpenClaw, simply switch the web search provider to SearXNG in the settings. Specify \`http://localhost:8888\` as the URL.

For Claude Code, you can connect via an MCP server. An MCP server for SearXNG is also publicly available.

## Comparison with paid APIs

Monthly estimate for paid search APIs (when using agents daily):

-   Brave Search API: Free tier is up to 2,000 requests per month. Exceeding this costs $5–$9/month
    
-   Tavily: Free tier is 1,000 requests per month. Exceeding this costs $20+/month
    
-   Perplexity API: $20+/month (assuming a Pro subscription)
    

With SearXNG, all of these are 0 yen. You only pay for the electricity to run it on your own machine. Even if you rent a VPS, it only costs a few hundred yen per month.

## Points to note

-   If you fetch a large volume of Google search results, you may be temporarily blocked. This can be avoided by adjusting the combination of search engines
    
-   Response speed may be slower than paid APIs (because it queries multiple engines)
    
-   If using it for a production service, setting up rate limits will ensure stability
    

## Summary

SearXNG is a tool that lets you "make paid search APIs free with a single Docker command."

If you are worried about the search costs of your agents, give it a try. Setup takes 5 minutes. It also eliminates the need to manage API keys, making operations simpler.

The search quality is not much different from paid APIs, yet the cost is zero. It is a tool worth knowing for individual developers.