Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

websearch

web_search and web_fetch tools, through one of two services.

require("websearch").setup({ count = 8 })
require("websearch").setup({ backend = "searxng", url = "http://localhost:8888" })

With backend = "exa", the default, both go through Exa’s public search service, so they need no key. The free service is rate limited, though; with a key from Exa in EXA_API_KEY, or in the key option, the limit goes away.

With backend = "searxng", web_search asks your own SearXNG instance, at url or SEARXNG_URL, and web_fetch reads the page itself and turns its HTML into text. SearXNG answers JSON only once it is allowed, under search.formats in its settings.yml:

search:
  formats:
    - html
    - json

Its limiter expects a proxy in front that sets X-Forwarded-For, and blocks requests that arrive without one. For an instance only you use, turn it off with server.limiter: false, or give url the proxy’s address rather than the SearXNG container’s.

OptionMeaningDefault
backendWhere searches go: "exa" or "searxng". Each is a module in websearch/backend/."exa"
urlThe SearXNG instance, for backend = "searxng".SEARXNG_URL
keyAn Exa API key, for backend = "exa".EXA_API_KEY
policyWhether the tools ask before they run: "allow", "ask" or "deny"."allow"
countResults per search.5
charsCharacters of a page that web_fetch returns at most.20000
timeoutSeconds per request.30