Is There a Free Open Source Alternative to Tavily?

2026-11-22
Brian

Subscribe
Get New Posts by Email
New RepoSquare posts in your inbox: comparisons, setup guides and explainers on open-source tools and AI coding agents. No spam, and you can unsubscribe anytime.

I put the same ten developer questions through two free search setups, five results each, and both answered in about two seconds. One handed my agent about 14,000 characters of page text per question. The other handed it about 79,000. That gap is most of the story when you try to replace Tavily.

So yes, there is a free open source alternative. SearXNG, a search engine you host yourself, plus a short Python script gives your agent what Tavily gives it: search results with the useful page text already pulled out. If your agent needs whole pages as clean Markdown, self-hosted Firecrawl does that too, but it wants far more memory.

Diagram of the three jobs a Tavily-style search tool does: search, fetch and clean, trim
The three jobs inside one Tavily call.

Here is how it usually goes. Your agent needs to look something up, you wire in a search API, it works, and then the free-plan limit or the bill shows up. Tavily’s free plan gives 1,000 credits a month, and every search uses at least one. That’s fine for a demo. It isn’t fine for an agent that searches ten times per task, so I built the free version, plugged it into Claude Code, and measured it against self-hosted Firecrawl.

What Tavily Does in One Call

Mind map of a free Tavily replacement: SearXNG searches, a Python script fetches and trims page text, an MCP server hands it to Claude Code, and Firecrawl is the heavier option for full pages.
The free replacement at a glance.

Tavily turns a question into short, readable page text, and that’s the part an agent can’t easily do alone. A normal search engine gives you a list of links with a one-line snippet each. A person clicks and reads. An agent can’t click, so it needs the words on the page handed to it.

Search engine link list compared with the page text an AI agent needs
What a search engine returns, and what an agent needs.

Any search tool for agents ends up doing three jobs:

  1. Search: send the question to search engines and get back links.
  2. Fetch and clean: download each page and strip menus, ads and footers, keeping only the article text.
  3. Trim: keep only the parts that answer the question, so the agent doesn’t burn tokens on the rest. A token is the small chunk of text a model reads and bills by, roughly four characters.

Tavily does all three behind one API call. Each result comes back with a title, a link, a relevance score and a content field built from the most relevant snippets of that page. The third job, trimming, is the one people forget. It turned out to matter most in my test.

SearXNG Script or Firecrawl: What Each One Gives You

Two open source setups cover it, and both lean on SearXNG for the search step. SearXNG is a metasearch engine, meaning it has no index of its own and asks Google, Bing and others for you, then merges the answers. It has a JSON API built in, so a script can call it like any other API.

Firecrawl is the second option. It turns web pages into clean Markdown, and its self-hosted version can search, but it doesn’t do the searching itself. Point it at a SearXNG server and it uses that. Without one, it falls back to DuckDuckGo.

Agent connected to SearXNG through a small script or self-hosted Firecrawl
Both setups lean on SearXNG for the search step.

Here is how the three compare, from my runs on those ten developer questions with five results each:

TavilySearXNG + scriptFirecrawl self-hosted
Cost1,000 free credits a month, then $0.008 per creditFreeFree
What you runNothing1 container5 containers
Memory usedNone on your sideAbout 150 MBAbout 2.6 GB, plus SearXNG
Time per question, 5 results with page textNot measuredAbout 2 secondsAbout 2 seconds
Pages with usable textNot measured44 to 45 of 5046 of 50
Text per questionTrimmed chunksAbout 14,000 characters (trimmed)About 79,000 characters (full pages)
LicensePaid serviceAGPL-3.0AGPL-3.0

I expected the table to split on speed. It didn’t, because the speed was a tie. The row that matters is text per question. Firecrawl hands your agent every word of every page, about 20,000 tokens per question. The script hands over about 3,500.

Bar chart of text per question: about 14,000 characters for the script, 79,000 for Firecrawl
Text handed to the agent per question.

Step 1: Run SearXNG With JSON Switched On

One config file and one Docker command give you a private search API on port 8888. SearXNG ships with JSON output off, because public servers get hammered by bots. On your own machine you want it on. Create a folder called searxng and put this settings.yml inside:

use_default_settings: true
server:
  secret_key: "change-me-to-a-long-random-string"
  limiter: false
  image_proxy: false
search:
  formats:
    - html
    - json
engines:
  - name: bing
    disabled: false
  - name: brave
    disabled: false

The engines part matters. Out of the box, my install sent general searches to only two engines, DuckDuckGo and Google’s custom search. DuckDuckGo started returning CAPTCHAs almost at once, so turning on Bing gave the setup a second engine that kept working.

Then start it, mounting that folder so SearXNG reads your settings:

docker run -d --name searxng -p 8888:8080 \
  -v "$PWD/searxng:/etc/searxng" searxng/searxng:latest

If the container exits with “Address family not supported by protocol”, your host has no IPv6 and SearXNG is trying to listen on it. Add -e GRANIAN_HOST=0.0.0.0 to the command and it starts. Then test it with one call that asks for JSON instead of a web page:

curl "http://localhost:8888/search?q=docker+compose+healthcheck&format=json"
Raw JSON response from a self-hosted SearXNG search API
The raw JSON a self-hosted SearXNG returns.

You get back JSON with a results list: title, URL, a short snippet and which engine found it. A search took about half a second to one second. That’s job one done.

Step 2: Turn the Results Into Page Text

A short Python script fetches each result, pulls out the article text and keeps only the paragraphs that match the question. Install the two libraries it needs:

pip install requests trafilatura

Trafilatura extracts the main text of a web page and drops the menus, cookie banners and footers. That’s job two. Job three is the best_chunks function. It scores every paragraph by how many words it shares with the question and keeps the best ones, up to 4,000 characters per page.

import concurrent.futures as cf
import requests, trafilatura

SEARXNG = "http://localhost:8888/search"

def best_chunks(text, query, max_chars=4000):
    words = {w for w in query.lower().split() if len(w) > 2}
    paras = [p for p in text.split("\n") if len(p) > 40]
    ranked = sorted(paras, key=lambda p: -sum(w in p.lower() for w in words))
    keep, size = [], 0
    for p in ranked:
        if size + len(p) > max_chars:
            break
        keep.append(p)
        size += len(p)
    return "\n".join(sorted(keep, key=paras.index))

def fetch_text(url, query):
    try:
        html = requests.get(url, timeout=8).text
        return best_chunks(trafilatura.extract(html) or "", query)
    except Exception:
        return ""

def search(query, max_results=5):
    data = requests.get(SEARXNG, params={"q": query, "format": "json"}, timeout=15).json()
    hits = data["results"][:max_results]
    with cf.ThreadPoolExecutor(max_results) as pool:
        texts = list(pool.map(lambda h: fetch_text(h["url"], query), hits))
    return {"query": query, "results": [
        {"title": h["title"], "url": h["url"], "content": t or h.get("content", "")}
        for h, t in zip(hits, texts)]}

Save it as agent_search.py. The pages are fetched in parallel, so five results take about as long as the slowest page. Across three runs of my ten questions, the whole thing took about two seconds per question, and 44 or 45 of the 50 pages gave clean text. The rest fall back to the search snippet, so the agent always gets something.

Terminal output of agent_search.py returning titles, URLs and page text
agent_search.py returning titles, links and page text.

My first version didn’t have best_chunks. It just cut each page at 4,000 characters. That small difference broke a real answer, and you’ll see it in the next step.

Step 3: Plug It Into Claude Code

Wrap the script in a tiny MCP server and Claude Code can call it like a built-in tool. MCP (Model Context Protocol) is the standard plug Claude Code, Cursor and most agent tools use to add outside abilities. A server that exposes one function is about ten lines with the official Python package:

from mcp.server.mcpserver import MCPServer
from agent_search import search

mcp = MCPServer("local-search")

@mcp.tool()
def web_search(query: str, max_results: int = 5) -> dict:
    """Search the web through my own SearXNG and return page text."""
    return search(query, max_results)

if __name__ == "__main__":
    mcp.run()

The import line differs between versions of that package. Older 1.x releases call the class FastMCP and import it from mcp.server.fastmcp. Then register the server in a mcp.json file:

{"mcpServers": {"local-search": {
  "command": "python3", "args": ["/full/path/to/search_mcp.py"]}}}

And ask a question that needs a lookup:

claude -p "Use the web_search tool to find the default timeout in Python's requests library" \
  --mcp-config mcp.json --allowedTools "mcp__local-search__web_search"
Before and after: cutting pages at 4,000 characters versus keeping matching paragraphs
Same search, same pages. Only the trimming changed.

With the first version, the one that cut pages at 4,000 characters, Claude answered correctly but said it had to rely on a third-party blog. The official Requests docs were in the results, but the timeout section sat further down the page than the cut, so the agent never saw it.

With best_chunks, the same question came back quoting the official docs word for word: “By default, requests do not time out unless a timeout value is set explicitly.” Same search, same pages. Only the trimming changed. That’s the third job Tavily does for you, and it’s why a plain “first N characters” cut isn’t enough. If you pay for tokens, the same trimming idea shows up in Does TokenEconomizer Cut Coding Agent Cost?.

When Firecrawl Is Worth Five Containers

Pick Firecrawl when your agent needs whole pages as clean Markdown instead of short answers, and you have the memory to spare. Its search endpoint does jobs one and two, and when you ask for Markdown it returns every result page in full. That’s great for research agents that summarize long docs or build a knowledge base. It’s wasteful for an agent that only needs a fact, because it reads around 79,000 characters per question instead of 14,000.

Memory used by each self-hosted Firecrawl container compared with SearXNG alone
Memory used by each Firecrawl container next to SearXNG alone.

The setup is also heavier. It runs as five containers: the API, a headless browser service, Redis, RabbitMQ and Postgres. The API alone used about 2.2 GB of memory in my run. Three things broke on the way up, and they’ll hit you on a small server too:

  • The default Compose file asks for 4 CPUs for the API, so it refuses to start on a 2-CPU box. Lower the cpus value.
  • It sets a raised open-files limit that some hosts don’t allow. Remove the ulimits block if the container fails with an rlimit error.
  • The browser service downloads its package manager the first time it starts, so that start needs internet access.

Once it runs, set SEARXNG_ENDPOINT to your SearXNG address in its environment, or search falls back to DuckDuckGo. One honest gap in my test: I only measured Firecrawl’s plain page fetch. I couldn’t get its headless browser path working on my test machine, so I have no numbers for pages that only render with JavaScript.

You don’t pay per search, but you inherit the search engines’ moods, and those change without warning. SearXNG doesn’t own an index. It borrows results from engines that don’t love automated traffic. In my runs from a cloud server, Qwant refused every request, Brave started answering “too many requests” after six questions, and DuckDuckGo kept throwing CAPTCHAs. Bing and Google’s custom search engine carried every query.

Which search engines answered a self-hosted SearXNG from a cloud server
Which engines answered from a cloud server.

A few habits make that blocking manageable:

  • Try it from your own connection first. My blocks came from a cloud server, and a home or small VPS address may fare better.
  • Turn on several engines so one blocking you doesn’t empty your results.
  • Expect weaker results on some questions. One search for “python requests default timeout” returned python.org‘s home page above the answer. Tavily ranks for you; here the search engines and your trimming decide.
  • Check the license before you build a product on it. Both SearXNG and Firecrawl are AGPL-3.0, which means if you change their code and let people use it over a network, you have to share your changes.

None of that is a dealbreaker for a personal agent or a small team. It’s a real cost if search is the core of a product you sell, and there, paying for Tavily buys you someone else handling the blocking.

Should You Stay on Tavily?

Stay if your agent runs fewer than 1,000 basic searches a month, because the free plan covers it and you run nothing. Stay if you want a ready-made answer field or news search, which Tavily has built in. Pay-as-you-go is $0.008 per credit, and a basic search uses 1 credit while an advanced search uses 2.

For everyone else the math is simple. SearXNG costs about 150 MB of memory and one Docker command, answers in about two seconds, and never sends a bill. If your agent also scrapes pages directly, scrapling vs BeautifulSoup covers that side. Start with SearXNG and the script, and add Firecrawl only on the day your agent really needs full pages.

Get New Posts by Email
New RepoSquare posts in your inbox: comparisons, setup guides and explainers on open-source tools and AI coding agents. No spam, and you can unsubscribe anytime.

Leave a comment